2013年9月24日星期二

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

In determining whether there is a shortcut when the error : Failed to find provider info for com.android.launcher2.settings


Note: In the normal millet and simulator query shortcuts

This is my part of the 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);
------ Solution ------ --------------------------------------
q: 1063105290 seeking advice


------ eference ------------------------------------ ---
issue is resolved
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;
}
------ eference ----------------------------------- ----
this code how to call ? ?

------ eference ------------------------------------ ---
ask your question is how to solve ? I encountered the same problem with you
you can ask the next ?
------ eference ------------------------------------ ---
/ **
* Create Shortcut
*
*** /
private void createShorcut () {

if (! hasShortCut (this)) {/ / determine whether the shortcut has been created
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 creation
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 the main entrance
sendBroadcast (addShortcut);
}

}
/ *
* determine whether the shortcut has been created
*
** /
public static boolean hasShortCut (Context context) {
String url = "";
System.out.println (getSystemVersion ());
if (getSystemVersion () <8) {/ / determine if the system version is less than 2.2
url = "content :/ / com.android.launcher.settings / favorites? notify = true ";
} else {/ / determine if the system is smaller than version 2.2
url = "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;
}

没有评论:

发表评论