How jump to Widget Activity of Android's Setting? - android

I want to click a button to jump to AppWidget of Android's Setting with intent or broadcast, but i don't find Intent.ACTION_XXX to Widget Activity.I try ComponentName but i don't know which package can complete this action. if intent is can't complete this action, can i use broadcasting to complete this action?
Who can tell me how jump to the appwidget of android's setting? Thanks.

It's not really clear what you mean by Settings widget. If it's the Android settings screen that you want, this should do it.
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS, 0));
Don't forget to vote up if you find this helpful ;)

Related

Return back to App after clicking on Accessibility Service

Please Please read the question complete before marking it as duplicate or vague
On clicking of a button I want to redirect the user to accessibility settings of the android mobile. Where user can click on the accessibility settings of the application. Here is the code that I am using for the same:
Intent dummyIntent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(dummyIntent, 1);
Problem: When user clicks on, I want that it should redirect back to my application and should not remain on the accessibility screen itself.
It's quite late but i had to make the same stuff. So my suggestion is to use onServiceConnected() overridden method in class that extends AccessibilityService . When user apply accessibility in the settings you can launch intent to desired activity inside onServiceConnected(). But you should keep in mind that after device reboot onServiceConnected() also called, so use some flag to make sure that is not user action.
try this :
Intent dummyIntent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
ActivityContext.startActivityForResult(dummyIntent, 1);

Stay on my activity when dialing

I am using the intent with ACTION_CALL to make call in my app:
str="tel:0123456789";
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(str));
startActivity(intent);
But it pops up the system dialing screen. I understand this is built into ROM and can not be customized. But Can I hide this screen and keep the user staying on my activity?
Did some googling and research here. But no clear answer so far.
It looks like you can't customize the dialing screen, but you can use a PhoneStateListener to get certain information about the phone call. See this link.

How to send application to Background?

How to send my application to Background use code?
How to catch event when "Home key" is pressed?
Many thanks !
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
this.startActivity(i);
Home key press event cannot be captured as an android security feature.
You can send your activity into the background using moveTaskToBack.
There's no way to catch a HOME key press, or even to detect that it was pressed. The closest you can come is to write a replacement Home screen that uses android.intent.category.HOME. I believe that the user would have control over which activity should get to handle such an intent.
You can't catch the home key... it would defeat it's purpose after all.
If you simply want to know when your Activity is no longer visible, override the onPause() and/or onStop() methods.
If you want to start doing something in the background at this point, you could create a Service. A Service will run in the background, unlike an Activity which is more likely to be killed.
If you want to send some data to this Service from your Activity, you can use Intents and Extras. If you want to send more than the simple types of data you can send with extras, use the Application class. (Described in more detail here)

Trapping filtered Intents from android

From my understanding, if an intent is invoked implicitly, android matches the intent object's contents against all intent filters in the following order: component, action, data and category, filtering out non-matching intents at each step. At this point if there are multiple intents filtered out, then it brings up the activity chooser.
Is there a way by which I can trap the final filtered result and do further filtering based on Extras and Flags? Would ResolveInfo be of any help to me in this case?
In effect, I want to process my custom logic before android brings up the Activity chooser.
Can someone please point me in the right direction, maybe a place in the android source code which helps me to do the above?!
Thanks a lot!
If you are the one calling startActivity(), you can use PackageManager and queryIntentActivities() to find out what the chooser would wind up showing. You can then roll your own chooser if you, er, choose.
If you are trying to intercept the starting of any and all activities on the device, this is not possible.

Android Default application

i would like to know how to show
the check box that makes some application the
default in the createChooser dlg.
thanks in advance.
yes David i would like to know how to clear the app from being default. also i would like to know whether i can call any intent if i know its action, category, package and "class name", can I?
I actually tried to call some activity i previously known its intent contents put some SECURITY EXP. raised. why?
Your question isn't 100% clear to me, so forgive me if I'm answering the wrong question. It sounds like you want to either:
Pop up the dialog that lets the user select your activity as the default to handle some intent; or
Check if your activity is the default for an intent.
I'll answer both.
To pop up the dialog that lets the user select your activity as the default to handle some intent, simply call startActivity() with that intent. If for example you wanted to register yourself as the default home screen you would simply:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
1 of 3 things would happen.
Either there is no default specified (and if a user just installed your app, it will clear the default value) and thus the pop up will appear, or you're already the default or someone else is the default.
If you're already the default, then awesome, just figure out how to handle the intent this once (maybe add an EXTRA that explains that this was just a test so your activity knows to finish() immediately).
If someone else is the default you'll need to walk the user through clearing defaults for that app. If no one is the default you may want to throw up a Toast notification that explains what the user should do.
Toast.makeText(this,
"Please check 'Use by default for this action' and then press 'MyActivity'",
Toast.LENGTH_LONG).show();
These are all sort of messy situations to handle and it would be better to check first before calling startActivity(). To do that, use ResolveInfo.
ResolveInfo res = getPackageManager().resolveActivity(intent, 0);
// Got to be a better way to determine if there is no default...
if (res.activityInfo.packageName.equals("android")) {
// No default selected
} else if (res.activityInfo.packageName.equals(getPackageName())) {
// We are default
} else {
// Someone else is default
}
Hope this helps! If you want to know about how to make it easy for the user to clear another app from being default, let me know.

Categories

Resources