Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
コンテンツプロバイダの一覧
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