I work with PhoneGap and I try to denied user from go page when using back button in mobile I search I found this code
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var snd = new Media("/android_asset/www/sfx/lbl.ogg");
snd.play();
document.addEventListener("backbutton", function (e) {
e.preventDefault();
}, false);
}
Also I would like to run ogg music on enter the appliction but it's not work both of them not work.
1.Android ogg files supported latest version only refer this confirm this ....
2.Change file format of audio file and run.
3.Then put your back key Listener inside ondeviceReady
document.addEventListener("backbutton", onBackKeyDown, false);
and write function on for onBackKeyDown
Related
I used video capturing code using built-in camera in an application, but it reporting issues some of android phones like OnePlus phones. in other phones it works perfectly, can anyone help me to solve this issue, i tried many times but it didn't work, I'm sharing my code below..
Acutually it is shows only in device like one plus, I try to use built-in cam for to recording video, in my project, After we click button for to record video, it will redirected to the built-in cam in the device, in other devices it's working perfectly. but in one plus version11 , after we click the button for to record video it will not redirected to built-in cam, it is just stuck with the same page.. this is the issue
private void captureVideo() {
Intent VideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (VideoIntent.resolveActivity(getPackageManager()) != null) {
VideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
VideoIntent.putExtra("android.intent.extras.CAMERA_FACING", 1);
VideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 3);
VideoIntent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION,true);
startActivityForResult(VideoIntent, VIDEO_REQUEST);
}
}
iam using this code to get the currently active tab open URL from Google Chrome browser.
public static string GetActiveTabUrl()
{
Process[] procsChrome = Process.GetProcessesByName("chrome");
if (procsChrome.Length <= 0)
return null;
foreach (Process proc in procsChrome)
{
// the chrome process must have a window
if (proc.MainWindowHandle == IntPtr.Zero)
continue;
// to find the tabs we first need to locate something reliable - the 'New Tab' button
AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar"));
if (SearchBar != null)
return (string)SearchBar.GetCurrentPropertyValue(ValuePatternIdentifiers.ValueProperty);
}
return null;
}
is there any way that I can return the current Profile name too? the profile name which I mean is found on the upper right part of the google chrome browser so it maybe has more than a profile with different names I want only to get the current name with the URL it comes from this function. I can open or use many profiles at the same time in google chrome, so I want to get the active Tab URL and the profile name with it or the email of that profile.
this an image of the profile name i want it from chrome to be sent with the currently active tab URL.
so i expect something like that for example to be done in c# to get the profile name
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "profile email"));
last thing it can be c# or java codes if it can be better do in it also any solution that can get it in any programming language, please help with any information.
Thanks in advance.
You are going to have to dive into the HTML a little bit. Use chrome's developer features and inspect the HTML. You will find what class the username is under and the text is stored as the title find an example below.
<a class="gb_b gb_ib gb_R" href="https://accounts.google.com/" role="button" tabindex="0" title="Google Account: FillerFirstName FillerLastName (fillerEmail#gmail.com)" aria-expanded="false"><span class="gb_db gbii"></span></a>
You can accomplish this in many different ways with C#. I would recommend Selenium.
I am working on a small File manager to get the hang of things on Android and I have cut/copy/paste operation. It seems to work fine, but I run into issues with pasting things. On my app it is displayed fine, but for it to be recognized by other apps, it requires that I reboot the phone. For example, if I cut/paste an image from the download folder to the DCIM folder, the gallery app does not display that image unless I reboot the whole phone. I am using an algorithm that takes data byte by byte. Its extremely inefficient, but I am not totally sure how to implement a faster algorithm.
Thanks.
No actually you wont need to reboot our phone. When you copy an image and paste it to other location your newly copied media file is not added to the android's ContentResolver. So you should scan your data using the class MediaScannerConnection
Eg:
When you paste a file you have the file right ?
Modify as your wish, this works fine
private void scanImage(File targetLocation) {
// Scans the media to load images
String mimetype = Utility.getMimeType(targetLocation.getAbsolutePath());
if(mimetype.contains("image"))
{
MediaScannerConnection.scanFile(context, new String[] { targetLocation.getPath() }, new String[] { "image/jpeg" }, this);
}
}
UPDATE
Callback should be like
either you can implement OnScanCompletedListener in your class and add unimplemented method, So you can pass this as callback OR you can use
OnScanCompletedListener listener = new OnScanCompletedListener() {
#Override
public void onScanCompleted(String path, Uri uri) {
// you will get the callback here
}
};
and pass listener as callback
I am setting up the Android Device Buttons to work with my app. According to the PG/Cordova documentation I should be able to just add an listener such as
document.addEventListener("backbutton", function() {
console.log('Back Button Pressed.');
}, false);
However, when using my Nexus 7 as a test device, nothing happens.
I have also tried adding the override directly into Java:
#Override
public void onBackPressed() {
super.loadUrl("javascript:onBackKeyDown()");
return;
}
But once again, seems to do nothing. Anyone else having this issue or fixed?
Thank you.
First of all, ur function write into the console.
document.addEventListener("backbutton", function() {
console.log('Back Button Pressed.');
}, false);
You should set your device as debugging tools (, you will find below a quick hint how to do it, for more info go here )
Connect your phone to the pc
On your phone: check USB debugging;
setting => Developer Option => USB debugging
On your phone: check unknown sources;
settings >> applications >> unknown sources = true
add your device to the ADT (in your SDK)
run the project directly from the pc to the mobile :
right-click on the project => Run AS => choose your device
NOW on Back button Click, "Back Button Pressed." will be printed in the console of Eclipse.
If your device is not connected to the Computer or if your device is not set as debugging tools, Nothing will change.
In General case Use "alert()" in stead of "console.log()" if you are testing on the device without setting it as debugging tools.
Beside, dont use the native java, use the original documentation of Cordova, just add the following code into your javascript files:
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to call Cordova methods
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown() {
// whatever you want to do
alert('Back button Pressed');
}
then you should add "onLoad()" to the body tag:
<body onLoad="onLoad()">
I have a storage box admin page that's supposed to open with Java Web Start. However, on all browsers on my MacBook, this doesn't happen and instead I just get a html page saved with contents: "v6.3.1a Web Tools 10.1.18.222 ".
Looking at the javascript code of the page, I see it is trying to detect if correct Java Web Start is installed:
function webstartVersionCheck(versionString) {
// Mozilla may not recognize new plugins without this refresh
navigator.plugins.refresh(true);
// First, determine if Web Start is available
if **(navigator.mimeTypes['application/x-java-jnlp-file'])** {
// Next, check for appropriate version family
for (var i = 0; i < navigator.mimeTypes.length; ++i) {
pluginType = navigator.mimeTypes[i].type;
if (pluginType == "application/x-java-applet;version=" + versionString) {
return true;
}
}
}
return false;
}
Which is called here:
function writeMozillaData(page) {
versionCheck = webstartVersionCheck("1.5");
if (!versionCheck) {
var pluginPage = "http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com";
document.write("The version of Java plugin needed to run the application is not installed. The page from where the plugin can be downloaded will be opened in a new window. If not, please click here: Download correct Java version.");
window.open(pluginPage, "needdownload");
} else {
window.location = page;
}
}
I put in an alert in the mimeTypes and notice that there is no mimeType of 'application/x-java-jnlp-file' which shows up in navigator.
Questions:
Is this what is causing the browser to interpret the content as just text/html and save the html?
How can I force the launch of Java Web Start here?
I do have firefox settings indicating that jnlp get handled by Java Web Start application, hence I suspect the browser is not interpreting the page as jnlp at all to begin with.
..there is no mimeType of application/x-java-jnlp-file which shows up in navigator.
Is this what is causing the browser to interpret the content as just text/html and save the html?
Almost certainly yes. Fix the content-type.