package com.eni.android.another.app;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class Ch7_AppelerUneAutreApplicationExempleActivity extends Activity {

	private static final String COM_ANDROID_SETTINGS = "com.android.settings";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Button launchMap = (Button) findViewById(R.id.launchMap);
		launchMap.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				PackageManager pm = getPackageManager();
				/* Verifier si l'activite cible existe */
				Intent intent = pm
						.getLaunchIntentForPackage(COM_ANDROID_SETTINGS);
				/* Executer l'activite cible */
				if (intent != null)
					startActivity(intent);
				else
					Toast.makeText(
							Ch7_AppelerUneAutreApplicationExempleActivity.this,
							R.string.l_application_n_est_pas_disponible_sur_l_appareil,
							Toast.LENGTH_LONG).show();
			}
		});

	}
}