将program1复制到paste2程序
的AndroidManifest.xml:
程序1:
<provider android:name="com.coperator.service.PreferenceProvider"
android:authorities="com.coperator.prefs" />
program2:
<provider android:name="com.coperator.service.PreferenceProvider"
android:authorities="com.program2.coperator.prefs" />
java代码:
program1: public static final String AUTHORITY= "com.coperator.prefs";
program2: public static final String AUTHORITY = "com.program2.coperator.prefs";
public static final Uri RAZ_URI = Uri.parse(ContentResolver.SCHEME_CONTENT+ "://" + AUTHORITY + "/" + RESET_TABLE_NAME);
Uri uri = SipConfigManager.RAZ_URI;
resolver.update(uri, new ContentValues(), null, null);
首先运行program1 normal,运行program2时出错:
04-19 11:05:05.965: E/ActivityThread(5197): Failed to find provider info for com.talkingoa.coperator.prefs
04-19 11:05:05.965: E/ActivityThread(5197): Failed to find provider info for com.talkingoa.coperator.prefs04-19 11:05:05.975: E/AndroidRuntime(5197): FATAL EXCEPTION: main
04-19 11:05:05.975: E/AndroidRuntime(5197): java.lang.RuntimeException: Unable to create service com.coperator.service.SipService: java.lang.IllegalArgumentException: Unknown URI content://com.program2.coperator.prefs/raz
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2323)
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.app.ActivityThread.access$2500(ActivityThread.java:135)
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1118)
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.os.Looper.loop(Looper.java:150)
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.app.ActivityThread.main(ActivityThread.java:4385)
04-19 11:05:05.975: E/AndroidRuntime(5197): at java.lang.reflect.Method.invokeNative(Native Method)
04-19 11:05:05.975: E/AndroidRuntime(5197): at java.lang.reflect.Method.invoke(Method.java:507)
04-19 11:05:05.975: E/AndroidRuntime(5197): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
04-19 11:05:05.975: E/AndroidRuntime(5197): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
04-19 11:05:05.975: E/AndroidRuntime(5197): at dalvik.system.NativeStart.main(Native Method)
04-19 11:05:05.975: E/AndroidRuntime(5197): Caused by: java.lang.IllegalArgumentException: Unknown URI content://com.talkingoa.coperator.prefs/raz
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.content.ContentResolver.update(ContentResolver.java:722)
04-19 11:05:05.975: E/AndroidRuntime(5197): at com.coperator.utils.PreferencesProviderWrapper.resetAllDefaultValues(PreferencesProviderWrapper.java:53)
04-19 11:05:05.975: E/AndroidRuntime(5197): at com.coperator.service.SipService.onCreate(SipService.java:798)
04-19 11:05:05.975: E/AndroidRuntime(5197): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2309)
04-19 11:05:05.975: E/AndroidRuntime(5197): ... 10 more
我不知道这是怎么回事
答案 0 :(得分:0)
在我的应用开发期间,我遇到了同样的错误。对我来说,在调用Content Provider时使用正确的Uri解决了错误。
在我的内容提供商中,我添加了一些Uri,例如:
String AUTHORITY = "com.package.example";
static Uri CONTENT_URI = Uri.parse(AUTHORITY);
(...)
URIMatcher.addURI(AUTHORITY, "entry", 1);
之后,在调用ContentProvider时,我做了
getContentResolver().getType(Uri.withAppendedPath(MyContentProvider.CONTENT_URI, "entry/1"));
这个问题没有再发生。