User manual - ソフトウェアマニュアルver.1.09(2014年7月25日)

25
2.21 アプリケーション起動
V-T500/V-N500 に搭載されているアプリケーションは、ユーザーアプリケーションからでも起動することが
できます。
アプリケーションを起動するにはパッケージ名称が必要です。パッケージ名称は「3 標準アクセサリ」以降
に記載の「ソフトウェア一覧」にも記載
されていますが、Android標準ライブラリの「PackageManager」でも
取得できます
以下は起動方法の概要になります。詳細な情報は「Android Developers」等の Android 公式サイトを参
してください。
アクティビティの取得
PackageManager を使い、パッケージ名から、アプリケーションのアクティビティ名を取得します。
起動に指定できる Activity は、AndroidManifest.xml で「android.intent.action.MAIN
android.intent.category.LAUNCHER」が定義されたもの一つだけなので、これに該当するアクティビティ
名を取得する必要があります。
【例】
Intent ifind = new Intent();
ifind.setAction(Intent.ACTION_MAIN);
ifind.addCategory(Intent.CATEGORY_LAUNCHER);
ifind.setPackage("jp.casio.vx.util.memo.text"); //パッケージ名
PackageManager pm = this.getPackageManager();
list<ResolveInfo> list = pm.queryIntentActivities(ifind, 0);
if( list != null ) {
ResolveInfo item = list.get(0);
String myClass = item.activityInfo.name; //Activity Class
}
上の例では、myClass にアクティビティの名称が入ります。
アクティビティの起動
アクティビティを取得すると、以下の例のように起動できます。
【例】
Intent irun = new Intent();
irun.setClassName("jp.casio.vx.util.memo.text", myClass);
startActivity(irun);
また、インテント引数に対応しているアプリケーションであれば、以下のように「putExtra」で指定することも
可能です。
【例】
Intent irun = new Intent();
irun.setClassName("jp.casio.vx.util.memo.text", myClass);
irun.putExtra( "FILEPATH", "/mnt/sdcard/xxx.txt" );
startActivity(irun);