display pdf within google drive - android

I found simple solution if anyone ask solution use these it is not necessary to use webview.
String fullPath = "https://drive.google.com/open?id=1svKjgGhtS90u7n4D64ZcnzGxh9-X4kJx";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fullPath));
startActivity(browserIntent);

I found simple solution if anyone ask solution use these it is not necessery to use webview.
String fullPath = "https://drive.google.com/open?id=1svKjgGhtS90u7n4D64ZcnzGxh9-X4kJx";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fullPath));
startActivity(browserIntent);

Related

Open PDF in browser

What I want to achieve is to display PDFs directly in browser.
private void openPDF(String url) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
}
With this method the PDF is downloaded, but I have to manually open it in order to see it.
I remember this method worked just fine a while a go, did something change in the intent or chrome maybe?
String format = "https://drive.google.com/viewerng/viewer?embedded=true&url=%s";
String fullPath = String.format(Locale.ENGLISH, format, "PDF_URL_HERE");
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fullPath));
startActivity(browserIntent);
If this can help.

How to use Uri.parse in android

Hi I'm testing on encryption & decryption of a web url & trying to develop intent to web browser.
String decrypted = DecodeAES.decrypt(AESkey, encrypted);
decryptedValue.setText(decrypted);
here i want to retrieve "decryptedValue" and to be placed in the Uri.parse
actually here the "decryptedValue" contains some website to be opened in webbrowser.
Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com"));
startActivity(browserIntent);
Please tell me how to use Uri.parse & what to be used.
Thanks in advance.
Change -
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("www.google.com"));
to -
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));

Open a URL in Android's web browser from application

How can I open a url in the android web browser from my application on clicking a button.
I tried this :
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(strURL));
startActivity(myIntent);
but I am getting exception:
but I got an Exception :
"No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com"
You are doing it fundamentally correct, you just need to include the full url.
String strURL="http://www.google.com";
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(strURL));
startActivity(myIntent);
Basically, the http is the protocol. It is the computer's way of trying to figure out how you want to open it. You might also be interested in https, if you want a secure connection over SSL.
Almost seems like this would be useful to read... from the page:
Uri uri = Uri.parse("http://androidbook.blogspot.com");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uri);
startActivity(launchBrowser);
There is a second way, involving the WebView, but that seems like it's not your question. Hope this helped.
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Try this:
String strURL = "http://www.google.com";
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(strURL));
startActivity(myIntent);
As for the missing "http://" I'd just do something like this:
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;

Facebook Link doesnt work android

Hello I just want to call Facebook app with the link below (on my android project):
String url_facebook_prixo = "https://www.facebook.com/pages/Prixo/468580313168290";
I tried this :
Uri uri = Uri.parse("facebook://facebook.com/page{468580313168290}");
Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(viewIntent);
I tried with others link but its only displaying my wall..
Someone?
You should use the id to open the page.
Intent facebookIntent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("fb://profile/468580313168290"));
startActivity(facebookIntent);
I would advice you to encapsulate this in a try catch. Inside the catch open a normal browser intent

opening local html file with Android Browser

i'm trying to open a local html file using the default browser using the following code:
Uri uri = Uri.fromFile(file);
Intent browserIntent = new Intent(Intent.ACTION_VIEW).setData(uri);
startActivity(browserIntent);
but i'm getting the following exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///sdcard/SolveDroid/solution.html }
i'm confused - should i create an activity to hande the web beowser? isn't it supposed to just call its activity?
please advise :)
UPDATE:
the same code works if i pass a URL like so:
Uri uri = Uri.parse("http://www.metalist.co.il");
Uri uri = Uri.fromFile(file);
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
browserIntent.setData(uri);
startActivity(browserIntent);
I found an answer for this problem... just needed to add
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
i used it with the "file://" uri by using Uri.fromfile(file) and it works (Android v.2.2.1)
try this
Intent in = new Intent(Intent.ACTION_VIEW);
File f=new File("/sdcard/html.html");
in.setDataAndType(Uri.fromFile(f), "text/html");
startActivity(in);

Categories

Resources