ã¤ã³ã¹ãã¼ã«æ¸ã¿ã¢ããªã®ä¸è¦§ãåå¾ããããæå®ã¢ããªãã¤ã³ã¹ãã¼ã«ããã¦ãããå¤å®ããã
PackageManagerã使ãã°è¯ããããã
import java.util.List; import android.app.Activity; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.util.Log; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // PackageManagerã®åå¾ PackageManager pm = this.getPackageManager(); // ã¤ã³ã¹ãã¼ã«æ¸ã¿ã¢ããªã±ã¼ã·ã§ã³ã®ä¸è¦§ãåå¾ List<ApplicationInfo> list = pm.getInstalledApplications(0); for (ApplicationInfo ai : list) { Log.i("PackageManagerTest", ai.packageName); } // ç¹å®ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããã¦ãããå¤å® try { ApplicationInfo ai = pm.getApplicationInfo("com.android.browser", 0); Log.i("PackageManagerTest", "com.android.browser is found"); } catch (NameNotFoundException e) { Log.i("PackageManagerTest", "com.android.browser is not found"); } } }