Created
August 12, 2020 05:33
-
-
Save junichim/68ba6b64f9315de5cac206ceaccc41fb to your computer and use it in GitHub Desktop.
コンテンツプロバイダの一覧
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.contentproviderinfo; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.content.pm.PackageManager; | |
import android.content.pm.ProviderInfo; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.widget.TextView; | |
import java.util.List; | |
public class MainActivity extends AppCompatActivity { | |
private static final String TAG = MainActivity.class.getSimpleName(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
dumpContentProviderInfo(); | |
} | |
private void dumpContentProviderInfo() { | |
List<ProviderInfo> info = getPackageManager().queryContentProviders(null, 0, 0); | |
for (ProviderInfo pi : info) { | |
try { | |
Log.d(TAG, "Application name: " + getPackageManager().getApplicationLabel(getPackageManager().getApplicationInfo(pi.packageName, 0))); | |
} catch (PackageManager.NameNotFoundException e) { | |
//e.printStackTrace(); | |
Log.d(TAG, "Application name: unkown"); | |
} | |
Log.d(TAG, "name: " + pi.name); | |
Log.d(TAG, "packageName: " + pi.packageName); | |
Log.d(TAG, "processName: " + pi.processName); | |
Log.d(TAG, "authority: " + pi.authority); | |
Log.d(TAG, "exported: " + pi.exported); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment