I'm trying to implement the fingerprint authentication and I want to make the user register a new fingerprint if He hasn't one. I know how to start an Intent to the Security Settings menu, but I can't find anywhere how to highlight the option I want the user to click. Do you think it's possible?
Thanks for your help
If you're targeting Android P and higher, you can take the user 1 step further with the specific Intent Settings.ACTION_FINGERPRINT_ENROLL.
You can use this way:
#RequiresApi(api = Build.VERSION_CODES.P)
private void startFingerprintEnrollment(#NonNull AppCompatActivity activity) {
Intent intent = new Intent(Settings.ACTION_FINGERPRINT_ENROLL);
activity.startActivityForResult(intent, REQUESTCODE_FINGERPRINT_ENROLLMENT);
}
For lower versions you can use what you're already using. Unfortunately there is no way to highlight the specific Setting row.
Related
In Android 9 media output controls were added to the volume selection dialog.
I would like to have a button in my app which would open these system media output controls so that the user can choose where the audio will be played.
I could find nothing about this in: Android 9 features and APIs, Behavior changes: apps targeting API level 28+ and Behavior changes: all apps
You are looking for MediaRouter API.
public class MediaRouterPlaybackActivity extends AppCompatActivity {
private MediaRouteSelector mSelector;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create a route selector for the type of routes your app supports.
mSelector = new MediaRouteSelector.Builder()
// These are the framework-supported intents
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
.build();
}
}
For further reference: https://developer.android.com/guide/topics/media/mediarouter#java
Also check Create a MediaRouteSelector section.
I did some research about this as well so I know that Android Pie is capable of this, but they haven't provided a way for us developers to do it yet (at least I haven't found a way). The CATEGORY_LIVE_AUDIO in MediaRouterSelector is also only for secondary output; you can read about it on the developer website. So if you must do it, I think the only way you can do that right now is to do a workaround programmatically:
Disconnect current device (The important of this step depends on the device; I have to do this on my Essential phone)
Use BluetoothAdapter.getBondedDevices() to get a list of paired devices.
Connect to the one you want
Try this - it works for me on Android 11:
Intent intent = new Intent("com.android.settings.panel.action.MEDIA_OUTPUT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
From my device owner application, I'd like to create a new user and switch directly to it. For now, I can only create a new user, switch to it but:
it brings me to the keyguard screen, that I need to manually unlock.
then, tells me to setup the newly created user - with firstname, lastname, WIFI settings, and 3 Google usage statistics/reporting options.
I'd like to know if there's a way to programmatically setup the new user and switch directly to it's "session". I'd like to programmatically avoid the "unlock" page et pre-setup the newly created user with name, WIFI settings, but also available apps and security settings.
here's what I do so far :
// init block (in onCreate...)
DevicePolicyManager mDPM = (DevicePolicyManager) this.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName mDeviceAdminRcvr = new ComponentName(this, DeviceAdminRcvr.class);
// in my button "create a new user"
ComponentName profileOwnerComponent = new ComponentName(this, ProfileAdminRcvr.class);
Bundle adminExtras = new Bundle();
UserHandle userHandle = mDPM.createAndInitializeUser(mDeviceAdminRcvr, name, ownerName, profileOwnerComponent, adminExtras);
// TODO : place here missing instructions to provision the user...
mDPM.switchUser(mDeviceAdminRcvr, userHandle);
I couldn't find any documentation on the official Google page about device owner apps or profile apps.
Could anyone help me or point me to useful links ?
As far as I've seen, there is no way to programmatically unlock the screen lock. Even the Smart lock functionnality added in Lollipop will just disable the Key Guard, which means that the "PIN" or "Pattern" will transform into a "Swipe Lock" when a trusted agent unlocks the device. Even in this case, you'll need to manually swipe the screen to unlock the device.
Concerning the second point, it's possible to avoid the "Setup Wizard" proposed the first time you unlock a newly created user. Here's how to do it :
in your ProfileAdminRcvr.java, you'll need to hide the system application called com.google.android.setupwizard. You could do this in the onEnabled() method of your DeviceAdminReceiver's implementation (the one you set for your profile when creating the user).
To complete this, you can disable the "first use hint", by setting the Settings.Secure.SKIP_FIRST_USE_HINTS property.
Here's the code to do it :
public class ProfileOwnerRcvr extends DeviceAdminReceiver {
private DevicePolicyManager mDPM;
private ComponentName mProfileAdminRcvr;
#Override
public void onEnabled(Context context, Intent intent) {
mDPM.setProfileName(mProfileAdminRcvr, "My new user");
// ... setup other things by yourself...
mDPM.setApplicationHidden( mProfileAdminRcvr, "com.google.android.setupwizard", true);
mDPM.setSecureSetting(mProfileAdminRcvr, Settings.Secure.SKIP_FIRST_USE_HINTS, "1");
}
Google updated its demo app to use Android-N preview version, it seems that there will be a flag called DevicePolicyManager.SKIP_SETUP_WIZARD to do part of what you are trying to do (i.e skipping the wizard) in N.
in agreement with the recent post from Android Developers http://android-developers.blogspot.pt/2013/10/getting-your-sms-apps-ready-for-kitkat.html ,I was trying to prepare my app to the new android version, but encountered a problem with the part they suggest to create a dialog to let the user set the app as the default application to handle SMS's :
Android Developers Post
public class ComposeSmsActivity extends Activity {
#Override
protected void onResume() {
super.onResume();
final String myPackageName = getPackageName();
if (!Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName)) {
// App is not default.
// Show the "not currently set as the default SMS app" interface
View viewGroup = findViewById(R.id.not_default_app);
viewGroup.setVisibility(View.VISIBLE);
// Set up a button that allows the user to change the default SMS app
Button button = (Button) findViewById(R.id.change_default_app);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent =
new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
myPackageName);
startActivity(intent);
}
});
} else {
// App is the default.
// Hide the "not currently set as the default SMS app" interface
View viewGroup = findViewById(R.id.not_default_app);
viewGroup.setVisibility(View.GONE);
}
}
}
the code itself in pretty much straightforward, but I'm unable to access to Telephony.Sms.getDefaultSmsPackage because it says that Telephony cannot be resolved, and I can't find any import or declaration that would fix that.
Can anyone please help?
android.provider.Telephony simply doesn't exist yet (as of API 18 - 4.3).
This class will be added in 4.4 (presumably API 19), and that blog post is highlighting the changes that you should make once the new API is released so you aren't surprised when the time comes.
From the end of the post:
To help you make the changes, we'll soon be providing the necessary SDK components for Android 4.4 that allow you to compile and test your changes on Android 4.4.
Don't forget that you should wrap this code in an API version check so you don't run into issues with older versions that don't have this class.
this change will break all the SMS blocking apps.
"Note that—beginning with Android 4.4—any attempt by your app to abort the SMS_RECEIVED_ACTION broadcast will be ignored so all apps interested have the chance to receive it."
Do you think there is a way to go around this?!
Maybe at least on Root?
Apparently there is with root access. The latest version Cerberus app claim to be doing this.
Now, if only I knew how they do it :(
The issue is that I need to install an apk(non market app) and for this, the user need to activate the unknown source setting, so i send him (if he didn't have it activated) to the settings so he can turn on the option, the issue is that i tested it in different phones and in samsung that option is on applications while in htcs phones is on security. i want send the user to that option but i don't know how to do it
I read about this and no one knows exactly how to do it
this is my code
int canInstallFromOtherSources = Settings.Secure.getInt(ctx2,Settings.Secure.INSTALL_NON_MARKET_APPS);
if(canInstallFromOtherSources == 0)
{
Intent intentSettings = new Intent();
intentSettings.setAction(android.provider.Settings.ACTION_APPLICATION_SETTINGS);
startActivity(intentSettings);
}
You can do it with the following line (changing to the corresponding action):
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), REQUEST_CODE_ENABLE_LOCATION_PROVIDERS);
Check Android Settings documentation.
I think you should use ACTION_SECURITY_SETTINGS and one of ACTION_APPLICATION_SETTINGS or ACTION_APPLICATION_DEVELOPMENT_SETTINGS.
And here (line 304), you've got a working example of one of my apps: Tureame
first off - let me just say that I am NOT asking how to implement a share button in my app or anything like that. I know all about using Intents and Intent Filters etc etc.
what I AM asking about is this: is there any way to get access to the "Share" menu itself? in other words, I'd love to build an app that filters out some of the services I never use but that I don't want to delete from my phone completely.
I tried looking it up in the Android API, but only found info on getting your app to show up in the menu or putting a 'Share' button in your app etc.
Being that I'm still somewhat of a novice programmer, I'm also wondering if there's some way for me to sniff out the API objects that are being created/used when the 'Share' menu is built/displayed? Seems like I could do it in a Debugger session, but I'm not sure how.
Thank you in advance.
b
Well, there are two ways to go around Share menu. First one is to use
startActivity(Intent.createChooser(Intent, CharSequence)
But in this case, I am not sure how to obtain an access to the created share menu, coz it is a separate activity.
However, if you wish to have a control over the list of share items being displayed for your app, there is another way to approach your share menu item implementation.
Take a look at this code snippet:
//Prepare an intent to filter the activities you need
//Add a List<YourItemType> where you going to store the share-items
List<YourItemType> myShareList = new List<YourItemType>;
PackageManager packageManager = mContext.getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
int numActivities = activities.size();
for (int i = 0; i != numActivities; ++i) {
final ResolveInfo info = activities.get(i);
String label = info.loadLabel(packageManager).toString();
//now you can check label or some other info and decide whether to add the item
//into your own list of share items
//Every item in your list should have a runnable which will execute
// proper share-action (Activity)
myShareList.add(new YourItemType(label, info.loadIcon(packageManager), new Runnable()
{
public void run() {
startResolvedActivity(intent, info);
}
}));
}
This code snippet shows how to get a list of the activities which are able to process share request. What you need to do next is to show your own UI. It is up to you what you are going to choose.