I'm trying to start default android wallpaper chooser. I'm using:
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(intent);
This code works but it opens app chooser. I want to open "Wallpapers" directly. My minSdkVersion is set to 16.
By "default" you seem to mean the wallpaper app that came with Android OS, rather than other wallpaper apps that the device may have. You can force Android to launch a particular activity by setting the component in the intent.
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
intent.setComponent(...);
startActivity(intent);
However, this is a risky thing to do. If you run this code on a device that doesn't have the wallpaper app that you've specified, then you will get an ActivityNotFoundException.
Do you really need to launch one particular wallpaper app? A central feature of Android is that you say what you want to do, and it finds the app to do it. I don't know what your goal is, but another function that might be helpful is PackageManager.resolveActivity. You can use it to discover, in code, what app would be launched for a particular intent.
http://developer.android.com/reference/android/content/pm/PackageManager.html
Hope this helps.
Related
I am using MediaStore.Audio.Media.RECORD_SOUND_ACTION to open sound recorder application, I am not able to open application as no default application present, then i install two voice recorder application even though not able to see these application in my chooser intent. I am using following code-
Intent soundRecorderIntent = new Intent(); // create intent
soundRecorderIntent.setAction(MediaStore.Audio.Media.RECORD_SOUND_ACTION); // set action
startActivityForResult(soundRecorderIntent, ACTIVITY_RECORD_SOUND); // start activity
It works well in marshmallow
The code is correct and you've probably found an app that supports the intent by now. But to prevent that others waste their time like I did, here's a quick note:
Most of the currently top rated voice recording apps in the Play Store do not provide the necessary intent filter.
That seemed so unrealistic to me that I doubted my code when it didn't work after having installed the five most popular voice recording apps. But there's a handy manifest viewer app that reveals that their manifests simply do not declare the intent filter. So, as said, the code is correct.
To save you the time from searching for a suitable app, here are two that are invocable:
Audio Recorder from Sony
Samsung Voice Recorder from Samsung
There is no requirement for a voice recorder app to support this Intent action, and apparently your device does not ship with an app that supports this Intent action either. Your code itself seems fine.
If recording is optional to your app, catch the ActivityNotFoundException and tell the user that they do not have a recorder, and perhaps suggest to them that they install one that you test that works, if you can find one.
Otherwise, record the audio yourself, using MediaRecorder.
I have a webview in my app, on trying to do actions like making a call (Tapping call button from results displayed in webview), sending mails and other actions, my webview doesn't perform those actions
I Found a solution to add the intent actions in my web view activity as
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(intent)
Instead of doing so is there any way to add in the android manifest file
or Is there any way to turn on all of the intent actions for the webview so that
there wont be further issues in handling the actions
Can someone help me on this pls
Your answer seems to me a bit strange, I think you are a bit confuse about the difference between Intent and manifest permission. The first one are the system used by android to let app communicate with each other, the second one allow you to use some feature of the device like wifi and direct phone call that need the explicit agreement of the user to be used (the prompt that popup when you make the first install of an app).
With this clarification it is clear that if you want to do something that require another app you will have to make an Intent. This Intent, if well formed, will be elaborated by the os that will take care of sending it to the correct application able to accomplish the Intentrequirement.
So the answer to your question, as far as i know, is no, you have to use intent if you have the need of calling external app. It's also a good practice to set in the manifest only the permission really needed by the app, this way the user know what the app really can do and and what it can't do.
Hope i understand your question and answer it.
I need to develop a Wallpaper application for Nook Color. I have installed the Nook color addon after that when i use this code in my app and it gets crashed every time. The below API Intent to allow any application to open the Wallpaper Settings Manager UI in Nook Color device
Intent i = new Intent();
i.setAction( "com.bn.nook.CHANGE_WALLPAPER" );
startActivity( i );
Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.bn.nook.CHANGE_WALLPAPER }
Please help, Thanks in advance.
This intent is only going to be available on Nook device.
Using this on any other device or emulator that isn't specifically designed to be the nook isn't going to work.
It would be like trying to open Internet Explorer on a machine which doesn't have Internet Explorer installed.
The code you have posted is a direct copy paste from (i assume) the official Nook Developer page here.
The code isn't inherently wrong, the Action your specifying simply doesn't seem to exist - you need to find the correct Action name from the Developers/Nook API.
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);
Can someone explain me how to control one application from another application? I'm running a music player in an app1 using service class. And I want to stop that music player from another app.,i.e app2. But, I'm fallin short o the concept.
Depends what you need to do.
Opening another activity (or sending messages) is by using Intents:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
// ...
startActivity(intent);
Starting service is by using startService()
What you are trying to do can also be done using Intent broadcasts but only if your target app supports and listens to specific actions on the broadcast. You need to see if there is such an ACTION supported.
I'd like to continue this question a bit.
In my case, I'm developing the target app and I need to implement few simple procedure calls for the main app. Basically 'start', 'stop' and 'sendData'. As I wrote, I'm developing the target app so I can support whatever I want. Which would you say is the easiest way to handle.
The whole situation a bit more explained. Main app would like my app to start it's work, and if needed they'll request that I turn myself off and when the main app is closing it would request me to send my data forward.
I'm quite new to android development, so code snippets are preferable. Thank you.