I have seen many posts asking how to link from a free android app to other paid version, and what I am doing is the following on the click method:
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse(Constantes.uriAplicacionFinal));
startActivity(i);
However, when it executes I get the following exception:
06-07 11:54:15.793: ERROR/AndroidRuntime(1703):
Caused by: android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.VIEW dat=market://details?id=com.autoescuela }
Everytime I have used Intents, I have used them like this:
Intent i = new Intent(this, Login.class);
i.putExtra(Constantes.intent_login, R.string.Login);
startActivityForResult(i, Constantes.activity_login);
So, I specifiy it which activity is the one that has to pick up the Intent, but I don't know what I have to specify to launch the Android market.
Seems that you are testing the application on an emulator as a result your market application is missing. Try to test the application on real handset, everything will be fine.
Related
I have this code, that works fine in Android 4.4 and previous:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setPackage("com.android.phone");
intent.setData(Uri.parse("tel:" + number));
context.startActivity(intent);
Now, in Android 5.0 Lollipop this code doesn't work, and shows this exception:
Fatal Exception: android.content.ActivityNotFoundException
No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxx pkg=com.android.phone }
In the documentation, this Intent doesn't appear deprecated:
Any idea? Thanks in advance
Seems like the package name has been changed from
com.android.phone
to
com.android.server.telecom.
Hope this helps!
An alternative to using the action String manually encoded is to use the default intent like so:
Intent out = new Intent(Intent.ACTION_CALL );
out.setData(Uri.parse("tel:" + Uri.encode("+12345#123")));
startActivity(out);
This will pass the intent to the system and all apps with phone capability will respond instead of the specific one determined via the action String
This means you are trying to call com.android.phone but it's not there. No miracles. It's not gonna work. Either the package is named differently or you are using semi-backed emulator or so with missing stuff. Not to mention you must always have try/catch around startActivity() as there's no guarantee it gonna success (especially when targeting external packages)
This one worked for me on Android 4.4:
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setPackage("com.android.dialer");
intent.setData(Uri.parse("tel:1111111111"));
startActivity(intent);
If using Eclipse, open the system dialer app and in DDMS, check for the name of the dialer package; in my case was "com.android.dialer".
I have an android application that requires VPN. My users will be using Galaxy Note 3's and will be using the built in "VPN Client" (com.ipsec.vpnclient). I need to find a way to launch this application from my application, in the instance of the VPN dropping. I've already figured out a way to determine if the VPN dropped, but I still need a way to launch the application.
ANSWER:
Thanks to help from #Muthu I was able to get it working with the following method.
final Intent intent = new Intent("android.intent.action.VIEW");
intent.setComponent(new ComponentName("com.ipsec.vpnclient", "com.ipsec.vpnclient.MainActivity"));
EDIT:
To add to the confusion, I am easily able to add a shortcut to the activity (com.ipsec.vpnclient.MainActivity) via another Launcher like ADW or Nova. I also tried using com.ipsec.vpnclient.MainActivity instead of com.ipsec.vpnclient in the method below, to no avail.
Intent intent = getPackageManager().getLaunchIntentForPackage("com.ipsec.vpnclient");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
The above method works with other packages, but I can't seem to get this one to launch.
Here is the application when viewed in Android System Info.
Any ideas on how to launch this application programmatically?
You can Start any installed application by using intent. in your case like this
Intent LaunchVPN = getPackageManager().getLaunchIntentForPackage("com.ipsec.vpnclient");
startActivity( LaunchVPN );
Edit
You can open pre installed apps that can be found inside settings page by
final Intent i = new Intent("android.intent.action.VIEW");
i.setComponent(new ComponentName("com.android.settings","com.android.settings.InstalledAppDetails"));
startActivity(i);
From within my app, I'd like to start the set up new email account activity of the Email App which looks like this: http://i.stack.imgur.com/BNYnj.png
I've looked at this http://source-android.frandroid.com/packages/apps/Email/AndroidManifest.xml
and tried to start the set up email activity:
Intent intent = new Intent("com.android.email.CREATE_ACCOUNT");
startActivity(intent);
But I got an exception:
E/AndroidRuntime(517): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.email.CREATE_ACCOUNT }
Anyone please help me?
Thanks so much,
John
you could try using an explicit intent. instead of
new Intent("com.android.email.CREATE_ACCOUNT")
use
new Intent(context, com.android.email.activity.setup.AccountSetupBasics.class)
you may also want to look into the whole ACTION_ADD_ACCOUNT action string. it may do what you are looking for without having to use a SPECIFIC app. for example, when an oem installs a different email app from the stock android one. if it happens there won't be anything to handle either the explicity or implicit intent.
This works for from APIs 4.0+.
Intent intent = new Intent("com.android.email.CREATE_ACCOUNT");
intent.putExtra("FLOW_MODE", 0);
startActivity(intent);
Below works for from APIs 2.1+. Maybe also work for lower versions (not tested).
Intent intent = new Intent();
intent.setClassName("com.android.email", "com.android.email.activity.setup.AccountSetupBasics");
intent.putExtra("FLOW_MODE", 0);
startActivity(intent);
I am trying to start AppB from AppA. On activity of AppB I issue:
Intent i = new Intent();
i.setAction("START_APPB");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.sendBroadcast(i)
Inside AppB I have a broadcast receiver that is listening on START_APPB intent filter.
as follows:
Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setAction("SHOW_APPBPAGE");
context.startActivity(i);
Note in each case context is the activities context of the respective app.
This causes a crash error from activity manager:
IllegalArgumentException: Can't use FLAG_RECEIVER_BOOT_UPGRADE here
I have never seen this error before. When i have sent same message from first activity of App it runs without error, but somehow not on 3rd page , using context of third page.
Do not use any FLAG_ACTIVITY_ constant with sendBroadcast().
When populating your Intent, do:
intent.setFlags(0);
I ran into this and found out that this is a bug in android. At some point in history this two flags - FLAG_ACTIVITY_NEW_TASK and FLAG_RECEIVER_BOOT_UPGRADE - get the same numeric value because some android developer changed one of their values without checking that it is already taken by another flag. The latest version (4.4) seems to have it fixed already.
I'm working on an app and I want to integrate the Last.fm app into it. Basically, when someone is looking at an artist in my app, I would like to have a button that they can tap to open up Last.fm application with the artist's information.
This intent works, but it loads a menu asking which app I would like to use (Browser or Last.fm):
Intent i = new Intent();
i.setData(Uri.parse("http://last.fm/music/" + headliner));
i.setAction("android.intent.action.VIEW");
startActivity(i);
However, I just want to start the Last.fm app and skip the dialog asking which app to use, I thought maybe using the setPackage() method would work like this:
i.setPackage("fm.last.android");
But it causes the app to crash:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://last.fm/music/Rihanna pkg=fm.last.android }
Is it possible to just start the Last.fm app? Here's a copy of Last.fm's AndroidManifest.xml for reference.
Thanks for reading,
Tony
Yes, it's possible but you need to know the correct component name. Launch the last.fm app regularly and check the logfile for the cmp=... information that's been used when the app is started. Use this as well in your app then.
I start the Z-DeviceTest app from the market from within my app without a problem like this:
final Intent intentDeviceTest = new Intent("android.intent.action.MAIN");
intentDeviceTest.setComponent(new ComponentName("zausan.zdevicetest","zausan.zdevicetest.zdevicetest"));
startActivity(intentDeviceTest);
in my case the info I took from the logcat was:
// dat=content://applications/applications/zausan.zdevicetest/zausan.zdevicetest.zdevicetest
// cmp=zausan.zdevicetest/.zdevicetest
in order to know how to start the app with the right component/class... do the same for the last.fm app
Edit:
I've tested to launch Last.fm from my own app, and this works fine without any errors:
final Intent intentDeviceTest = new Intent("android.intent.action.MAIN");
intentDeviceTest.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm"));
startActivity(intentDeviceTest);