I am trying to open the settings page using intent for peripheral devices in tablet .
But i am finding no parameters in action_settings.
Please help me . your help will be much appreciated
That would appear to be a custom change to the Settings app made by that manufacturer. The manufacturer might be able to suggest an Intent that leads to that particular screen. However, you will not find a documented Intent action in the Android SDK for it, as it is not a standard Settings screen.
If you wanted to try an undocumented approach, you could check Logcat and see what entries are logged when you click the Settings item to open that screen. Activity starts get logged with some Intent details, and you may be able to reverse-engineer the Intent that your app can use that way.
Related
I want to make an activity in my native android app that doesn't allow to change to other apps, or open settings or go back to home screen, just like the alarm apps do when the alarm comes in, but I can't find anything about how to do this.
Does anybody know how to do this?
I'm building a background service app without any UI on Android 11. Right now I'm using below code to ask for user consent to install apk with permission "SYSTEM_ALERT_WINDOW"
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
context.startActivity(intent);
With this code, the program will be able to prompt to user for consent of installation when there is a new apk coming in.
But could someone tell me how can I get the result of user's choice and the result of whether installation success or fails? I know we can use startActivityForResult but since this is a background service app, I'm not able to use that since it doesn't have any activity.
I don't know if this is too late for you. What I use to get a callback is packageInstaller.registerSessionCallback(new PackageInstaller.SessionCallback() {}. You can implement a bunch of overriden methods inside this which will help you monitor the progress. Again I use this inside activity and haven't tried it in a service. Also, even though I got a call back for user cancelling the pop up, I couldn't get one for installing update successfully. These are my observations. Hope this would give you some insights.
I have a custom launcher and at times want to add a button to launch third party applications. To do this I need the apps package name, which is easy to find, but also the apps main or starting activity. I use this to create Intents that I pass to my app.
For example, to create an intent that launches Skype I use:
`new Intent().setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"))
I was able to find the name of the main activity by Googling around and as Skype is a popular app it showed up eventually.
I know that if I have the APK I can just open it and look at the androidmainifest , however I'm not sure how to get the APK's of some apps at all. For instance, I want to start this app from Google Play . I can see the package name, com.dbapp.android.mediahouse, however I'm not sure how to get the name of the main activity(I tried .MAIN).
I've looked at the Chrome extension apk downloader that supposendly allowed you to get APK's from Google Play but it appears to no longer work.
I know starting third party apps from a custom launcher is something that must be fairly common, but I'm not finding the answer when I search.
How do people typically handle this issue? Do you get the APK from the Google Play Store and if so how does one do that? Again, I know that I can get the activity from reading the manifest but I don't know how to get the APK itself in many cases. Any advice would be very much appreciated, thanks!
A launcher should be finding the MAIN/LAUNCHER activities advertised by apps on the device, by using PackageManager and queryIntentActivities(). Here is a sample app that implements such a launcher.
PackageManager pm=getPackageManager();
Intent main=new Intent(Intent.ACTION_MAIN, null);
main.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> launchables=pm.queryIntentActivities(main, 0);
You then use that List<ResolveInfo> to display the available activities in a ListView, GridView, etc.
The PackageManager offers a method to get exactly what you want:
PackageManager.getLaunchIntentForPackage(String packageName)
You can use Intent intent = new Intent(android.content.Intent.MAIN);
or like the example behind to launch Maps and parse a URI:
String uri = "http://maps.google.com/maps?saddr=" + Utils.getLatitude(ShowDetails.this)+","+Utils.getLongitude(ShowDetails.this)+"&daddr="+userLatitude+","+userLongitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
I am new to android. I am making an application for reading the pdf files. For this i want to integrate some existing open source apk with my application. Please suggest and give me example, how i can bind the apk with my application and how to call the apk from within the application activity. I think there should be something used by intent but not sure. Also if there can be any code to develop our own pdf reader, please share. Thanks.
As i know, integrating an apk directly from another application is not possible. This can not be achieved unless you know the source code of the apk. If this is the case.
Now its like this if you want to invoke Application2 from Application1 then you have to add one more intent filter in the Application2, you have to define an action in Application2 Manifest like
<action android:name="com.app2.intent.action.INVOKE_APP2"/>
and then define intent in your Application1 as
Intent i=new Intent("com.app2.intent.action.INVOKE_APP2");
startActivity(i);
It only possible if you know exactly what kind of intent (Action, data, type) the activities in that apk would be able to react.
You can use either startActivity(intent) or startActivityForResult(intent) once you know what the intent should be like.
An APK is not source code. You cannot directly interact with it if it was not meant to allow this, through intents. If you're starting on Android, I suggest you take some time familiarizing yourself with intents and intent-filters, they're one of the "unique" aspects of Android development, and you can do quite powerful things when you know what you're doing.
http://developer.android.com/reference/android/content/Intent.html
But please note in order to do that, you need to have the user install both apps (the original apk and yours). As far as I know, there is no way to "embed" an apk within your own app.
Also, please have a look at that question and this one, they overlap a little bit what you're asking.
I am having trouble clearing my app's activity stack. At the start of my app I make the user login and give them a session id. After they login they are able to continue on using the app. However if there session expires I want to redirect them to the login activity and clear the Activity history so they can't have access to the app. I looked at the Android API and the Intent flag FLAG_ACTIVITY_CLEAR_TASK seems to be want I want but it was just included in API level 11 and no phones have the new OS yet. Does anyone have a solution to this problem. Thanks.
I found my answer here. Turns out that I have to broadcast an intent to tell all of the Activities to call the method finish().
The documentation for FLAG_ACTIVITY_CLEAR_TOP describes the situation you want if you use it in conjunction with FLAG_ACTIVITY_NEW_TASK
http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP
"This launch mode can also be used to good effect in conjunction with FLAG_ACTIVITY_NEW_TASK: if used to start the root activity of a task, it will bring any currently running instance of that task to the foreground, and then clear it to its root state. This is especially useful, for example, when launching an activity from the notification manager."