How to Open Calculator In ANDROID
Rabu, 03 April 2013
0
komentar
The above may not work with every devices, so you may need this one..
public class CalculatorActivity extends Activity {
public static final String CALCULATOR_PACKAGE ="com.android.calculator2";
public static final String CALCULATOR_CLASS ="com.android.calculator2.Calculator";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent calculatorintent = new Intent();
calculatorintent.setAction(Intent.ACTION_MAIN);
calculatorintent.addCategory(Intent.CATEGORY_LAUNCHER);
calculatorintent.setComponent(new ComponentName(CALCULATOR_PACKAGE,CALCULATOR_CLASS));
CalculatorActivity.this.startActivity(calculatorintent);
} }
ArrayList<HashMap<String,Object>> items =new ArrayList<HashMap<String,Object>>();
PackageManager pm;
final PackageManager p = getPackageManager();
List<PackageInfo> packs = p.getInstalledPackages(0);
for (PackageInfo pi : packs) {
if( pi.packageName.toString().toLowerCase().contains("calcul")){
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("appName", pi.applicationInfo.loadLabel(p));
map.put("packageName", pi.packageName);
items.add(map);
}
}
if(items.size()>=1){
String packageName = (String) items.get(0).get("packageName");
Intent i = p.getLaunchIntentForPackage(packageName);
if (i != null)
startActivity(i);
}
else{
// Application not found
}
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: How to Open Calculator In ANDROID
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidpopuler.blogspot.com/2013/04/how-to-open-calculator-in-android.html. Terima kasih sudah singgah membaca artikel ini.Ditulis oleh Unknown
Rating Blog 5 dari 5
0 komentar:
Posting Komentar