2010年11月13日土曜日

android: 他のアプリを起動させる(CreateProcessの意味)

アンドロイドのアプリで他のアプリを起動させるのはintentを使ったらOKです。
例のコード:
  あるアプリがtien.helloのpackageにあり、マインのアクティビティはhelloであれば呼び方は下通りです。
String clazz = "tien.hello.hello";
            Intent intent = new Intent(Intent.ACTION_MAIN);

            int idx = clazz.lastIndexOf('.');
            String pkg = clazz.substring(0, idx);

            intent.setClassName(pkg, clazz);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);

0 件のコメント:

コメントを投稿