Android shortcut db launcher

I want to get data from db startup.

final String AUTHORITY = "com.android.launcher2.settings"; final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/favorites?notify=true"); Cursor c = contentResolver.query(uri, columns, null, null, null); 

and

 <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/> <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/> <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" /> <uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" /> 

but he said in logcat:

 Failed to find provider info for com.android.launcher2.settings 
+6
source share
2 answers

Launcher is an application under the responsibility of the phone manufacturer. Power then is not always "com.android.launcher2.settings" . The tube manufacturer can rewrite your own. It could be "com.android.twlauncher" or something else depending on the Java package.

You need to get the correct permissions by searching for a provider that declares read / write permissions to "com.android.launcher.permission.READ_SETTINGS" or "com.android.launcher.permission.WRITE_SETTINGS" .

This is sample code for this:

 static String getAuthorityFromPermission(Context context, String permission){ if (permission == null) return null; List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS); if (packs != null) { for (PackageInfo pack : packs) { ProviderInfo[] providers = pack.providers; if (providers != null) { for (ProviderInfo provider : providers) { if (permission.equals(provider.readPermission)) return provider.authority; if (permission.equals(provider.writePermission)) return provider.authority; } } } } return null; } 

Typically, the structure of ContentProvider and DB is preserved, and you can use the same queries.

+8
source

My Nexus 5 device requires different permissions

 <uses-permission android:name="com.google.android.launcher.permission.READ_SETTINGS"/> <uses-permission android:name="com.google.android.launcher.permission.WRITE_SETTINGS"/> 

Authorization string com.google.android.launcher.settings

0
source

Source: https://habr.com/ru/post/903740/


All Articles