カスタムコンテンツプロバイダを作成しました。これにはさらにいくつかのアプリケーションからアクセスできます。私は、プロバイダのAndroidManifest.xmlファイルにアクセス許可タグを含めました.2番目のアプリケーションでは、使用許可タグが含まれていましたが、成功しませんでした。 Logcatは私を示します:権限拒否:オープンプロバイダ
java.lang.SecurityException: Permission Denial: opening provider com.company.contentprovider.AplicacaoContentProvider requires READ_DATABASE or WRITE_DATABASE.
私は同様の質問で検索しましたが、すべて正しいと思われます。何か案は ? ありがとうございます!ここで
は私のプロバイダAndroidManifest.xmlファイルです:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.contentprovider"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission android:name="READ_DATABASE" android:label="@string/app_read" android:protectionLevel="normal"></permission>
<permission android:name="WRITE_DATABASE" android:label="@string/app_write" android:protectionLevel="normal"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".CompanyProvider"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name="AplicacaoContentProvider"
android:authorities="com.company.contentprovider"
android:exported="true"
android:readPermission="@string/app_read"
android:writePermission="@string/app_write"
/>
</application>
そして、これは私の第二のアプリケーションのAndroidManifest.xmlファイルです:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testeprovider"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permissions.READ_DATABASE"/>
<uses-permission android:name="android.permissioms.WRITE_DATABASE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.testeprovider.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
ありがとうべきであるかどうか質問があります!私はすぐに仕事に着きますが、私はこれらの変更を行い、結果についてあなたに知らせます! –
それはあなたの言ったとおりに機能しましたが、別の疑問があります。私は、私のコンテンツプロバイダにアクセスする20以上のアプリケーションを持っています。コンテンツプロバイダが存在するかどうかを各アプリで確認する必要があります。そうであれば、データの記録にパーミッションを使用するだけです。それ以外の場合は、プロバイダを登録してからデータを記録します。ですから、私は、各アプリケーションのAndroidManifest.xmlファイルにpermissionタグとuses-permissionタグの両方を入れるようなものを考えました。それはうまくいくの? youtube downloader –
@MauricioAlencar:「私は、コンテンツプロバイダが存在する場合は、私のアプリケーションの一つ一つ確認したいことがない場合、単に。データを記録する権限を使用します。それ以外の場合はプロバイダを登録し、dat a。 "それは非常に悪い計画です。 20のアプリケーションをすべて完全に独立させてください。あなたの計画では、ユーザが20人のうち1人をアンインストールすると、1人が「ContentProvider」に決定した1人になったとすれば、20人すべてのアプリケーションのデータが失われます。 – CommonsWare