Is It Possible To open 2 url At a time from android app without opening the layout.
I can open these two in two different activity or using two button in same activity.
Uri uri = Uri.parse("http://www.facebook.com");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
Uri uri = Uri.parse("http://www.gmail.com");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
Is it possible to open them from same activity directly as the application start??
AFAIK You can not open two links at the same time and view in activity.As you can have access to the single activity at a time in android, So browser is a kind of activity which you are requesting for opening url. You can not show two different links at a same time.
But yes its possible to open link directly at the start up of application.
Related
I have a problem with a feature of my application.
I need to open external files to display them like .jpeg or .xls for example. For that I use Intents to open them with the default system application and it works fine.
But in a case where we will first open a document, for example a photo. this will display in the default app and then I go back and forth in my app. Everything is OK
But then I'm going to open another standard .xls document, it'll open the document in the appropriate application and going back will show the opened image first and not my application again.
I don't understand why it happens like this.
What I would like is that when we do previous in a file viewer app, the app quits and doesn't stay in the ActivityManager.
Is it possible ?
I have already tried some intent flags but without success.
My code here :
Android.Net.Uri fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, "com.app.fileprovider"
, file);
Intent intent = new Intent(Intent.ActionView);
intent.SetData(fileUri);
intent.AddFlags(ActivityFlags.GrantReadUriPermission);
intent.AddFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.NoHistory);
Android.App.Application.Context.StartActivity(intent);
return true;
Thanks a lot for the help
Max B
SO !
My bad, It was not a real problem.
It was a design error.
Indeed during my call of my function to call the intention I linked my opening event without then unbinding it. So that with each call I recalled X times my file opening function without ever destroying my variable or my variable instance.
The Intent Works Well
Thanks for the comments
So, there are apps that can create shortcuts on the home screen.
My question is, How can my app opens/runs/starts a certain shortcut?
if I have 2 browser shortcuts, each of them loads a different url ... how can I choose between them? how to choose to open the 1st or the second one?
To open a URL/website you do the following:
String url = "http://www.example.com";
Intent mIntent = new Intent(Intent.ACTION_VIEW);
mIntent.setData(Uri.parse(url));
startActivity(mIntent);
Here's the documentation of Intent.ACTION_VIEW.
I want to let the user to visit my website by click a button.
However, I want the app to open the google chrome or other external web browser to open the website instead of load the url with WebView.
How can I do that?
You can do it with an ACTION_VIEW Intent --
Uri myUri = Uri.parse("http://www.whereever.com/");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(myUri);
startActivity(intent);
If you want to do it on a button click, you will need to put it in the onClick method of your onClickListener.
I'm developing a pre-load-type application... the desktop icon needs to take you directly to the market details page where you can download the full app. i can't seem to figure out how to go straight to the market, bypassing any kind of actual application screen.. the application screen loads for a split second, displaying the value from the android:label tag from the manifest... then the market details loads.
Step #1: Add android:theme="#android:style/Theme.NoDisplay" to the <activity> element for your launcher activity.
Step #2: Call finish() just after calling startActivity() to bring up the Market activity.
try this:
Uri marketUri = Uri.parse("market://details?id=" + packageName);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
I'm downloading a PDF in my application using:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("*url for your pdf*"));
startActivity(browserIntent);
This opens an activity that looks like a webview and begins the pdf download in the drop down menu. I'd like to keep the drop down download notification but is there a way to close the webview activity once the download starts? Or even better keep the webview from popping up in the first place?
Instead of calling a Uri intent, you could download the file to the sd card if it is not already there (using notification for progress), then call action_view on the file. That should open it directly in the preferred PDF viewer.