他アプリケーションのContextを取得する(Android) †他アプリの Context を取得する †アプリケーションで定義されたリソース(文言や画像)等は、基本的にそのアプリの Context からしか取得できないが、 例) package example.utils; import android.content.Context; public class ContextUtil { public static Context getOtherContext(Context context, String package, int flags){ return context.createPackageContext(package, flags); } } ※ packageには対象のアプリケーションの パッケージ名を指定する。 flags に指定する値は以下の通り。
参考 † |