我的应用程序在启动列表视图后崩溃了。我的列表视图是该程序中运行的第一个活动。我没有编译错误,也不理解收到的logcat错误。我认为这个问题可能在我的清单中。任何援助将不胜感激。下面是我的logcat和清单。
logcat的:
07-16 22:42:55.129: E/AndroidRuntime(1448): FATAL EXCEPTION: ModernAsyncTask #1
07-16 22:42:55.129: E/AndroidRuntime(1448): java.lang.RuntimeException: An error occured while executing doInBackground()
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:137)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.lang.Thread.run(Thread.java:856)
07-16 22:42:55.129: E/AndroidRuntime(1448): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.loginplus.home.ListProvider from ProcessRecord{41c4be20 1448:com.example.listviewrefresh/10041} (pid=1448, uid=10041) that is not exported from uid 10040
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.os.Parcel.readException(Parcel.java:1327)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.os.Parcel.readException(Parcel.java:1281)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2201)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4024)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1612)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.content.ContentResolver.acquireProvider(ContentResolver.java:918)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.content.ContentResolver.query(ContentResolver.java:305)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:35)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:240)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
07-16 22:42:55.129: E/AndroidRuntime(1448): at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
07-16 22:42:55.129: E/AndroidRuntime(1448): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-16 22:42:55.129: E/AndroidRuntime(1448): ... 4 more
Listview活动:
public class LoginList extends FragmentActivity implements AdapterView.OnItemClickListener, OnClickListener, LoaderManager.LoaderCallbacks<Cursor> {
private ListView loginList;
private Button webLogin;
private SimpleCursorAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_listview);
loginList = (ListView)findViewById(R.id.loginlist);
loginList.setOnItemClickListener(this);
webLogin = (Button)findViewById(R.id.button3);
webLogin.setOnClickListener(this);
//Specify fields to display in the list
String[] from = new String[] {ListProvider.COLUMN_NAME_SITE};
//Bind fields to listview
int[] to = new int[] {R.id.loginlist};
// Create CursorAdapter and set it to display
adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null, from, to, 0 );
loginList.setAdapter(adapter);
getSupportLoaderManager().initLoader( 0, null, this);
}
@Override
public void onItemClick(AdapterView<?> l, View v, int position, long id) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Selected ID :" + position, Toast.LENGTH_SHORT).show();
Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class);
Cursor clickedObject = (Cursor)loginList.getItemAtPosition(0);
Bundle loginBundle = new Bundle();
loginBundle.putString("clickedWebSite",((LoginDetails) clickedObject).getsName());
loginBundle.putString("clickedWebAddress",((LoginDetails) clickedObject).getwUrl());
loginBundle.putString("clickedUserName",((LoginDetails) clickedObject).getuName());
loginBundle.putString("clickedPassWord",((LoginDetails) clickedObject).getpWord());
loginBundle.putString("clickedNotes",((LoginDetails) clickedObject).getlNotes());
updateDeleteLoginInfo.putExtras(loginBundle);
startActivityForResult(updateDeleteLoginInfo, 0);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent webLoginIntent = new Intent (this, LoginPlusActivity.class);
startActivity(webLoginIntent);
}
@Override
public Loader<Cursor> onCreateLoader(int ignored, final Bundle args) {
String [] columns = { ListProvider.COLUMN_ROWID, ListProvider.COLUMN_NAME_SITE};
CursorLoader cursorloader = new CursorLoader(this, ListProvider.CONTENT_URI, columns, null, null, null);
return cursorloader;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
adapter.swapCursor(cursor);
}
@Override
public void onLoaderReset (Loader<Cursor> loader) {
adapter.swapCursor(null);
}
}
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.listviewrefresh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".LoginList"
android:label="@string/app_name" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginDB"
android:label="@string/app_name" >
<intent-filter >
<action android:name="com.example.listviewrefresh.LOGINDB" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".LoginDetails"
android:label="@string/app_name" >
<intent-filter >
<action android:name="com.example.listviewrefresh.LOGINDETAILS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".UpdateDeleteLoginList"
android:label="@string/app_name" >
<intent-filter >
<action android:name="com.example.listviewrefresh.UPDATEDELETELOGINLIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".LoginPlusActivity"
android:label="@string/app_name" >
<intent-filter >
<action android:name="com.example.listviewrefresh.LOGINPLUSACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".dataStore"
android:label="@string/app_name" >
<intent-filter >
<action android:name="com.example.listviewrefresh.DATASTORE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<provider
android:authorities="com.example.listviewrefresh.ListProvider"
android:multiprocess="true"
android:exported="false"
android:readPermission="com.example.listviewrefresh.ListProvider.READ_DATABASE"
android:writePermission="com.example.listviewrefresh.ListProvider.WRITE_DATABASE"
android:name="com.example.listviewrefresh.ListProvider"></provider>
</application>
</manifest>
答案 0 :(得分:1)
根据logcat
07-16 22:42:55.129: E/AndroidRuntime(1448): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.loginplus.home.ListProvider from ProcessRecord{41c4be20 1448:com.example.listviewrefresh/10041} (pid=1448, uid=10041) that is not exported from uid 10040
它正在尝试打开一些我无法在您的清单中看到的提供商(com.loginplus.home.ListProvider
)。
理想情况下应该打开com.example.listviewrefresh.ListProvider
,您还有其他提供商吗?
答案 1 :(得分:1)
这种看起来像你可能正在移植应用程序,不是吗?
如果没有看到您正在使用的ListProvider
课程的详细信息,我们无法确定,但您的ListProvider.CONTENT_URI
似乎是错误的URI。
错误消息表示您无法访问清单中的com.loginplus.home.ListProvider
,而不是com.example.listviewrefresh.ListProvider
。
如果这实际上是来自其他应用程序的内容提供程序,如果android:exported
属性为false,则会出现错误。
要解决此问题,只需更新您的ListProvider.CONTENT_URI
以匹配清单中的那个,或者如果您尝试与其他应用对话,请将android:exported=true
添加到其他应用的内容提供商。