I have tried every simple combo I have found but not sure how to do this.
I even tried to simulate the home long press but you get google now voice, lookint at logcat it shows this
com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity
but not sure if this is what I am looking for or how to replicate it.
This works:
startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
So I've been trying to do the same thing, and just discovered something when I'm trying to launch the Assistant with an Intent like this:
Intent launchIntent = new Intent(Intent.ACTION_VIEW);
launchIntent.setPackage("com.google.android.googlequicksearchbox");
launchIntent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.staticplugins.opa.OpaActivity");
startActivity(launchIntent);
Although this doesn't throw an ActivityNotFoundException, it does throw a Permission Denial. This is shown to happen because Google Assistant must be launched from the googlequicksearchbox package from above. Hopefully this will change when/if they release an API for it. Fingers crossed.
Related
I am trying to open the Network Operator Settings view with the following code:
startActivity(new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS));
It works correctly on all the devices I could test, but on one of them (Alcatel One Touch Pixi, with Android 5.1) the Network Operator Settings view opens and automatically closes after that. I tried to see if the resolveActivity with the packageManager of that Intent returns null, but it does not, it opens the activity of network operator settings and then (for some reason) it automatically finishes.
Anyone can help me to fix this issue that only happens with some specific mobiles?
There's an alternative way to call the Network Settings menu:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.phone", "com.android.phone.MobileNetworkSettings"));
startActivity(intent);
This method works with Samsung devices but not sure about devices that you mentioned (since I'm specifying the name of the package and the activity class name).
I think you can try and if works, you may add the proper conditions to use this code etc.
You cannot fix the issue. The other app has a bug. Only its developers can fix the bug.
wireless settings
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
Network Operator Settings
startActivity(new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS));
Firstly, I understand that commonly this is not something that you typically want to do. However, the app I'm developing adds functionality to another app, but requires that the other app be restarted for it to work.
Is it possible to restart another app (i.e. -> user clicks a confirm button, other app is closed and reopened)? How would I accomplish this?
If it's not possible normally, would it be possible if the app has SU? How would it be accomplished then?
I found a way that no need root permission.
ComponentName componentName = getPackageManager().getLaunchIntentForPackage("com.xxx.yyy.zzz").getComponent();
Intent intent = IntentCompat.makeRestartActivityTask(componentName);
startActivity(intent);
There are some ways to interact with other apps through Android. Usually, intents are used for this.
You can go through this tutorial that shows what are the possible things you can do with other apps using your activity.
Especially, see the Lesson: Sending the User to Another App
I was able to uncover an answer... hopefully this will be helpful to those of you looking for the same.
Using RootTools, this is very easily done.
RootTools.killProcess(package);
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(package);
startActivity(LaunchIntent);
I have this piece of code
private void initiateInstallation() {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File("/sdcard/example.apk"));
intent.setDataAndType(uri, "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
that from within my service installs an application named example.apk
I want after the installation is finished to run an activity which notifies the user about the installation.I did that except the activity appears before the installation finishes.
The problem is that within a service I cannot use startActivityForResult. So, I need a way around this so that I can start my notification activity(or for the sake of example just print something out with Toast within the service) only AFTER the installation is complete.
I already tried some answers from other questions like "alternative to startActivityforResult in services" but still I couldn't figure this out.
I also put the code so that maybe there may be something done in there.
Thanks in advance ... any suggestions are welcome.
You could listen to the PACKAGE_ADDED broadcast intent: http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED
As far as I know, these are sent after the installation is done, and you can listen to those from the service.
Just note that if the application was already installed, you will get ACTION_PACKAGE_CHANGED (as far as I know).
Also you must know the package name as well, not just the apk name, since the intent will contain the package name.
The answer given by #Pal Szasz is technically correct (as far as I know ;-) ).
However, based on the information given in your question, I assume you only wish to show a notification (no further programmatically actions are to be performed). If my assumptions are correct I would respectfully advise you NOT to show such a notification. And this is why:
The Android system already has a standard means of passing notifications to the user. The status bar will in this case already show you a message saying that the new app is successfully installed (or not installed in case of an error). If you implement yet another notification channel you will most likely confuse or irritate your users by diverging from the standard, expected behaviour.
Taking this beyond the borders of sanity one could also argue for the fact that you in some sense also would contribute to the fragmentation of Android (in a very small scale, but nevertheless).
I'm trying to write a launcher-like application (I'm not planning to release it, it's just for me to use) but I don't seem to find any way to launch the Market.
All of the answers I've found actually perform a search on the Market (using a uri "market://") or even worse they run the Market on a specific app page, while I'm trying to show the main page of the Market, i.e. the page shown when you run it from the launcher.
I tried using just "market://" as a Uri, without query strings, but it doesn't work; I also tried to get exactly the same "signature" of the "start activity command" that appears in the LogCat when I run the Market from the Launcher (by manually editing component, flags and categories), but it still doesn't work.
Is there any way to get it to show the main page?
Thanks in anticipation.
Intent intent = new Intent();
intent.setClassName("com.android.vending", "com.android.vending.AssetBrowserActivity");
startActivity(intent);
I just wanted to "help" my users to give feedback to my app by providing a button to launch Market. Found a working solution here, of course, which does:
Uri uri = Uri.parse("market://details?id=<mypackagename>");
Intent intent = new Intent (Intent.ACTION_VIEW, uri);
startActivity(intent);
Simple as that, thanks!
But: on my first run, I had that on my emulator. Gives an ActivityNotFoundException immediately.
Now, my question: is there a way to find out whether a call to this intent will succeed BEFORE I try it? That way I could hide the button completely to not even give the option.
Thanks for your much appreciated help!
Instead of using this URL, you can use this one:
https://market.android.com/details?id=<mypackagename>
Even if the user doesn't have the Market application, he could go to the Website.
If he has the Market application, he should have a prompt between Internet and Market.
BTW, surround your code with a try catch in case he has nothing ;o)
You can also use this method.
Instead of IMDB, use your market URL: market://details?id=<mypackagename>
The exception was thrown just because there is no Android Market on the emulators. Every Android-powered device has the Android Market, so you shouldn't worry about this exception being thrown on a real device. Hope this helps.