//======= For Google Maps Check============
public boolean isGoogleMapsInstalled() {
try {
ApplicationInfo info = getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public OnClickListener getGoogleMapsListener() {
return new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.apps.maps"));
startActivity(intent);
//Finish the activity so they can't circumvent the check
finish();
}
};
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListAdapter adapter = new CustomArrayAdapter(this, demos);
setListAdapter(adapter);
//======= For Google Maps Check============
if (!this.isGoogleMapsInstalled()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Install Google Map ?");
builder.setCancelable(false);
builder.setPositiveButton("Install", getGoogleMapsListener());
AlertDialog dialog = builder.create();
dialog.show();
}
}