Rectangle 27 4

After a bit of Googling, this is what I could conclude:

Media capture in mobile browsers still seems to have some issues. Check out this link. The excerpt says:

Actually, it seems that current implementations dont rely on the capture attribute at all, but only on the type and accept attributes: the browser displays a dialog box in which the user can choose where the file has to be taken, and the capture attribute is not taken into consideration. For example, iOS Safari relies on the accept attribute (not capture) for images and videos (not audio). Even if you dont use the accept attribute, the browser will let you choose between Take Photo or Video and Choose Existing

So looks like capture attribute does not make any impact.

UPDATE: After downvoting, I dig further deep regarding the issue. Most of the searches resulted in no success as the optimum solution for this issue is to use Cordova camera plugin. Finally stumbled on this SO post which is exactly duplicate of this question. The user was able to resolve the issue (using crosswalk web view, though). The answer in that post is mentioned here already by @Fabio. But instead of adding the plugin just for including the permissions, you can make use of cordova-custom-plugin to add the required permissions.

Also as per @jcesarmobile's comment (who is a Cordova expert) in the post without crosswalk web view plugin, input type works fine only on iOS and not on Android. So using camera plugin is the only way to make it work without using crosswalk plugin.Hopefully, it helps.

UPDATE 2: After the updated question, I dug bit more deep for the resolution of this issue. But now I can assure that this issue is still not resolved for Android Webview. Looks like it is not a Cordova issue but issue with Chromium web view.

Both these issues are unresolved till date. So I m sure that for now, you cannot make it work on Android unless you use Cordova camera plugin. Hope you agree with me and accept the resolution. Cheers

@aWebDeveloperOf course its for cordova. Cordova app also uses webview which in turn uses browser capabilities. Also this question talks about cordova 3.6 which is way too old. If you have someother problems, please update the question. Also a kind request, downvoting never motivates any one. If the answer was not helpful please comment it.

thanks for the time taken. I have update the question to remove cordova 3.6 and also stressed that i want it with without cordova camera. +1 for custom config plugin

html - Choose camera in file upload in cordova application on android ...

android html cordova camera
Rectangle 27 5

The only way to overcome this is to perform a synchronous Ajax request which will block your browser while it runs, but will preserve the event context. This will help---> Open new tab without popup blocker after ajax call on user click

Here is the sample code for you --->

<table>

    <tr>
        <td>Works without warning in all browsers:</td>
        <td><input type="button" onclick="performSyncronousRequest()" value="Syncronous request"/><td>
    </tr>

    </tr>
</table>
/**
* This method will give open the popup without a warning.
*/
function performSyncronousRequest() {
    $.ajax({
     url: '/echo/html',
     data: {},
     success: function(){
         window.open('http://www.w3schools.com');
     },
     async: false
    });
}

You can checkout the code.Works like a gem.Cheers :)

i am not using ajax. i want to redirect on new page at the time of page load. so in jquery ready block i had written window.open("myurl", '_blank'); this code but it shows me pop-up blocker

This is the only workaround to open a path without popup(working cross browser).Using ajax is easy huhh.You can embed an ajax call in your webpage :)Cheers

i created fiddle but not working for me can you suggest changes. [ jsfiddle.net/23JNw/81 ] (jsfiddle.net/23JNw/81)

How can I open a link in a new tab? Using JavaScript or jQuery. Withou...

javascript jquery html
Rectangle 27 3

An old question but I just faced this problem. It turns out that the simplest way to achieve what you want is include these cordova plugins in you app, even if you don't need to use them

cordova-plugin-camera
cordova-plugin-media-capture
cordova-plugin-device
cordova-plugin-file
cordova-plugin-media
<input type="file" />

Ask you to choose from camera, camcorder, microphone or documents

Ask you to choose from camera or documents

<input type="file" accept="image/*" capture="capture" />

html - Choose camera in file upload in cordova application on android ...

android html cordova camera
Rectangle 27 1

Intent i=new Intent(FirstActivity.this, SecondActivity.class);
 i.putExtra("file", fileUrl);
 startActivity(i);

in SeconActivity, Use WebView

Intent i = getIntent();
    String myPdfUrl = i.getStringExtra("file");
    String url = "http://docs.google.com/gview?embedded=true&url=" + myPdfUrl;
    String doc="<iframe src='"+url+"' width='100%' height='100%' style='border: none;'></iframe>";
    WebView web=(WebView)findViewById(R.id.webViewpdf);
    webView.getSettings().setJavaScriptEnabled(true); 
    webView.loadData(doc, "text/html", "UTF-8");
<LinearLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent">

    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webViewpdf"/>

</LinearLayout>

Thank you @userJP but this code providde options for opening PDF file in Drive or Browser(Chrome, firefox,etc.). I want to open inside the SecondActivity only.

Open PDF file in my android application without using any browser or t...

android pdf pdfviewer external-application
Rectangle 27 2

var win = window.open('http://stackoverflow.com/', '_blank');
if(win){
    //Browser has allowed it to be opened
    win.focus();
}else{
    //Broswer has blocked it
    alert('Please allow popups for this site');
}

i don't want to display popup blocker. so without popup blocker can i achive this?

can you cross check my code. it gives me pop-up blocker. http://jsfiddle.net/23JNw/81/

How can I open a link in a new tab? Using JavaScript or jQuery. Withou...

javascript jquery html
Rectangle 27 0

<a href="http://www.bing.com" target="_blank">Open BING in new tab</a>

Tried to get around the inline CSS and put it in the <style> tag instead

@user3811037 target="_blank" is not CSS, it's just HTML.

@user3811037: Dark Ashelin is absolutly right. But what is wrong with that? I mean why do you want to define the target in CSS, when you can easily with a good-old HTML attribute? I just dont understand. Sorry. :)

Thanks DNReNTi - have been reading that inline attributes and CSS are frowned upon. But like I said, I'm new. Thanks Dark Ashelin - yep, you're right - changed my post.

@user3811037 Just want to make sure you're not mistaking that all HTML attributes are frowned upon, as they are generally not frowned upon. A specific exception, however, is the style attribute, which allows inline CSS to be applied to an element. The style attribute is generally frowned upon, since it is inflexible for applying styles, makes code maintenance much more difficult, and clutters your HTML making it less readable. This "frowned upon" status doesn't apply if it's added dynamically with JavaScript, since that wouldn't live in your HTML source code, just the rendered code.

Open link in new tab in HTML5 without using CSS in Chrome - Stack Over...

html5 google-chrome
Rectangle 27 0

You could use a Webview class if you want a view want to shown or you could use Rest/Post webservices with HttpUrlConnection/Androidhttpclient classes if you are interested in data part and dont want a view to be shown

Opening URL without using Web browser in Android Development - Stack O...

android android-intent
Rectangle 27 0

Assuming you have a reference to the android.view.View that draws your Screen (or your class Screen extends View), you can do this:

Context context = view.getContext(); // or Context context = getContext();
if (context instanceof Activity) {
    Activity activity = (Activity) context;

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/"));
    activity.startActivity(intent);
}

By the way, you can use any context to start an activity. Sometimes people make a static variable in their application object and use it as the context everywhere.

java - Android Development: Opening link in browser without using Acti...

java android browser game-physics
Rectangle 27 0

Do you mean that you want to parse the actual content of the webpage to your application? When I did so in one of my apps, I parsed the whole webpage with a simple http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html and then I took out those tags which where relevant. This however requires some pretty heavy dynamical programming running under an asynctask (http://developer.android.com/reference/android/os/AsyncTask.html).

I'm personally not very experienced with Android yet and I'm still learning but you should be able to parse the news from a webpage this way.

Edit: This approach pretty much requires some kind of identification of the certain "news-tags", Antons answer is better if they are "undefinable".

open a url without help of android browser in android? - Stack Overflo...

android browser
Rectangle 27 0

After trying to use InAppBrowser plugin with no avail I found the following snippet. This seems to work in Android for Cordova 3.3. (I chose to bind the <a> element to a click event in order to execute the javascript code)

$('#link-forgotPass').bind('click', function() { navigator.app.loadUrl('your.url.here', {openExternal:true}); });
<a href="#" rel="external" id="link-forgotPass" >Forgot Password?</a>

javascript - Open URL in Browser Cordova Android - Stack Overflow

javascript android html cordova
Rectangle 27 0

NOTE: to make window.open('somelink', '_system') to work you now need a device-level plugin, the inAppBrowser. Here are the installing instructions as of Cordova 3.0

As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI's plugin command, described in The Command-line Interface, to add or remove this feature for a project:

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
$ cordova plugin rm org.apache.cordova.core.inappbrowser

These commands apply to all targeted platforms, but modify the platform-specific configuration settings described below:

<feature name="InAppBrowser">
    <param name="ios-package" value="CDVInAppBrowser" />
</feature>
_system

@dannytenaglias go ahead and put that in your answer. Something like: NOTE: to make window.open('somelink', '_system') to work you now need a device-level plugin, the inAppBrowser. Here are the installing instructions as of Cordova 3.0:

javascript - Cordova 3.0 - Open link in external browser in iOS - Stac...

javascript ios cordova
Rectangle 27 0

I found that I had to be sure I was passing "http://" as part of my link when opening with the '_system' context. Trying to open "google.com" did nothing, trying to open "http://google.com" worked.

Sorry, this isn't the solution in this case - all URLs were being passed the full HTTP prefix.

Open Links in Default Browser using Phonegap/Cordova - Stack Overflow

cordova
Rectangle 27 0

Here's the code I'm using until cordova works as before. As you can see it's a method you already tried. Try cordova plugin -l to make sure you've got the inappbrowser. I installed via: cordova plugin add org.apache.cordova.inappbrowser which is a bit different than the older instructions.I'm using Cordova V3.2 .

window.onclick = clickEvent;

function clickEvent(e){
    e = e || window.event;
    var t = e.target || e.srcElement
    if ( t.name || t.href ){
       if( typeof t.href == "string" && t.href.substr(0,4) == 'http' ){
           if( t.attributes.href.value !== "#" ){
               window.open(t.href, '_system', 'location=yes');
           }
           return false; // no further action for this click
       }
    }
    return true; // process click as normal
}

The inappbrowser now works for my project. I had to upgrade the inappbrowser plugin, then had to upgrade android, and upgrade cordova and eclipse so that everything worked.

Open link in external browser from Android with cordova - Stack Overfl...

android cordova
Rectangle 27 0

it will show you the best methods available to open a pdf in android i dont think there is a way to open without using either of these things mentioned above

public class MyPdfViewActivity extends Activity {

    @Override
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mWebView=new WebView(MyPdfViewActivity.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo);
setContentView(mWebView);
 }
 }

"LinkTo" is the path of file in sdcard?

Thanks for your reply !!!! webview does not allow to add annotation in PDF,so how can i achieve this ??

Open PDF in android application without using library & installed read...

android
Rectangle 27 0

There is no way to read pdf without any library, you can use PDFViewer.jar library to read pdf into your application, use below SO link's answer for read PDF using PDFViewer.jar

Download Jar file from below link.

Thanks for your reply !!!! I want to add annotation on PDF like highlight,search text etc in my app. PDFViewer convert PDF into images so how can I achieve this target using this lib ??

Open PDF in android application without using library & installed read...

android
Rectangle 27 0

I have found the following description on Android Developers site:

As another example, the Android Browser application declares that the web browser activity should always open in its own taskby specifying the singleTask launch mode in the element. This means that if your application issues an intent to open the Android Browser, its activity is not placed in the same task as your application. Instead, either a new task starts for the Browser or, if the Browser already has a task running in the background, that task is brought forward to handle the new intent.

As you can see android:launchMode=singleTask is the right choice in your case. You already mentioned that you had issues with this property so maybe let's focus on them.

Note from Google regarding singleTask launchMode:

The other modes singleTask and singleInstance are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications.

singleTask and singleInstance use case from Google:

As you can see singleTask may not be recommended for general use but your case is not general, actually it's one of the cases where singleTask fits perfectly. In other words, singleTask is not forbidden, it's just need to be used with caution in order to provide end users common experience with your app.

I've tried it (put my package ID as the Affinity) but it is not working. I think because my task was not started yet, so the activity will open in the calling task.

It should be opened in new task even if your activity was not started. Can you tell how do you determine that your activity is in the same task?

Two indications: FIRST: in task manager I see only one task (the messaging task) and when clicking on it i see my activity. SECOND: running "adb shell dumpsys activity" in "Running Activities" i see one task with two activities: mms and my activity.

I've put my package name as the Affinity, is that correct?

Yes, it's fine. Did you remember to set allowTaskReparenting along with affinity? Can you also explain why do you need your activity to be in the separate task? Maybe we could come up with another solution for the initial reason.

open android activity in new task without using android:launchMode="si...

android android-intent
Rectangle 27 0

<a onclick="openThatLink()">store.spyfly.tk</a>

function openThatLink() {
            window.open('http://store.spyfly.tk', '_system', 'location=yes');
}

html5 - How can my Phonegap-App open a Link in the Android Browser? - ...

android html5 cordova phonegap-build
Rectangle 27 0

Thanks for the Reply. Media plugin is working fine on a button click at any time. But if it is working once in a first page load why not it can work on second or 3rd page loads

I am not sure I understand your question. onload will work whenever the page is loaded initially or at any subsequent refresh. So if this is what you mean have you tried checking the logs in the android console or using weinre?

I have done that. But on subsequent page loades I'm getting the 'Media' is not defined error

javascript - Playing audio in Android Cordova Project without using th...

javascript android cordova audio
Rectangle 27 0

$('#myButton').click(function () {
    var redirectWindow = window.open('http://google.com', '_blank');
    redirectWindow.location;
});

How can I open a link in a new tab? Using JavaScript or jQuery. Withou...

javascript jquery html