Monday, April 14, 2014

Help Failed to find provider info for com.android.launcher2.settings


Shortcuts in judging whether an error exists when: Failed to find provider info for com.android.launcher2.settings


Note: In the normal query millet and simulator shortcuts

This is part of my code:
if (android.os.Build.VERSION.SDK_INT <8) {
AUTHORITY = "com.android.launcher.settings";
} Else {
AUTHORITY = "com.android.launcher2.settings";
}

final Uri CONTENT_URI = Uri.parse ("content :/ /" + AUTHORITY
+ "? / Favorites notify = true");


Cursor c = cr.query (CONTENT_URI, null, null, null, null);
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Problem solved
static String getAuthorityFromPermission (Context context, String permission) {
if (permission == null) return null;
List 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;
}
Reply:
This code how to call? ?

Reply:
q: 1063105290 seek advice


Reply:
The question is how do you solve? I encountered a problem like you
You can ask under it?

        


Reply:
/ **
* Create a shortcut
*
*** /
private void createShorcut () {

if (! hasShortCut (this)) {/ / determine whether to create shortcuts
String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
Intent addShortcut = new Intent (ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext (this, / / ​​shortcut pictures
R.drawable.ic_launcher);
addShortcut.putExtra ("duplicate", false); / / do not allow duplicate create
addShortcut.putExtra (Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
addShortcut.putExtra (Intent.EXTRA_SHORTCUT_NAME, "Ah Habitat") ;/ / shortcut name
addShortcut.putExtra (Intent.EXTRA_SHORTCUT_INTENT, new Intent (
getApplicationContext (), WelcomeActivity.class)) ;/ / run the program's main entrance
sendBroadcast (addShortcut);
}

}
/ *
* Determine whether to create shortcuts
*
** /
public static boolean hasShortCut (Context context) {
String url = "";
System.out.println (getSystemVersion ());
if (getSystemVersion () <8) {/ / if the system version to determine
less than 2.2url = "content :/ / com.android.launcher.settings / favorites notify = true?";
} Else {/ / if the system version to determine
little more than 2.2url = "content :/ / com.android.launcher2.settings/favorites notify = true?";
}

ContentResolver resolver = context.getContentResolver ();
Cursor cursor = resolver.query (Uri.parse (url), null, "title =?",
new String [] {context.getString (R.string.app_name)}, null);

if (cursor! = null && cursor.moveToFirst ()) {
cursor.close ();
return true;
}

return false;
}
private static int getSystemVersion () {/ / Get the system version
return android.os.Build.VERSION.SDK_INT;
}
Reply:
Recently I have encountered, this is best tested once your android phone's native launcher application package name, I take the approach that loops through the application has been installed, and then find out your native launcher corresponds to the package name, and then splicing that Uri, I tested a
possibleI do not know q: 1162965454

No comments:

Post a Comment