android content Intent Intent Intent set ActionString act

  • Slides: 14
Download presentation

関連クラス 概 要 android. content. Intentクラス Intent() インテンツを作成する。 Intent set. Action(String act) アクションを設定する。 Intent

関連クラス 概 要 android. content. Intentクラス Intent() インテンツを作成する。 Intent set. Action(String act) アクションを設定する。 Intent set. Data(Uri uri) URIデータを設定する。 Android. app. Activityクラス void start. Activity 新しいActivityを起動する。

プログラム例(その1) package jp. tele; import android. app. *; import android. os. *; import android.

プログラム例(その1) package jp. tele; import android. app. *; import android. os. *; import android. content. *; import android. net. *; import android. view. View. On. Click. Listener; import android. widget. *;

プログラム例(その2) public class Tele. Activity extends Activity { Button btn; /** Called when the

プログラム例(その2) public class Tele. Activity extends Activity { Button btn; /** Called when the activity is first created. */ @Override public void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); Linear. Layout LL=new Linear. Layout(this); LL. set. Orientation(Linear. Layout. VERTICAL); set. Content. View(LL); btn=new Button(this); btn. set. Text("電話"); LL. add. View(btn); btn. set. On. Click. Listener(new tel. Click. Listener()); }

プログラム例(その2) class tel. Click. Listener implements On. Click. Listener{ @Override public void on. Click(View

プログラム例(その2) class tel. Click. Listener implements On. Click. Listener{ @Override public void on. Click(View v) { Intent it =new Intent(); //インテ ント作成 it. set. Action(Intent. ACTION_VIEW); //アクシ ョン指定 it. set. Data(Uri. parse(“tel: 0423069072”)); //デー タ設定 start. Activity(it); //電話の 起動 } } }

プログラム例(その1) package jp. retr; import android. app. *; import android. os. *; import android.

プログラム例(その1) package jp. retr; import android. app. *; import android. os. *; import android. content. *; import android. view. View. *; import android. widget. *;

プログラム例(その2) public class Retr. Activity extends Activity { Button button; /** Called when the

プログラム例(その2) public class Retr. Activity extends Activity { Button button; /** Called when the activity is first created. */ @Override public void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); Linear. Layout LL=new Linear. Layout(this); LL. set. Orientation(Linear. Layout. VERTICAL); set. Content. View(LL); button=new Button(this); button. set. Text("検索"); LL. add. View(button); button. set. On. Click. Listener(new ret. Click. Listener()); }

プログラム例(その3) class ret. Click. Listener implements On. Click. Listener { public void on. Click(View

プログラム例(その3) class ret. Click. Listener implements On. Click. Listener { public void on. Click(View v) { Intent intent=new Intent(); intent. set. Action(Intent. ACTION_SEARCH); intent. put. Extra(Search. Manager. QUERY, "Android"); start. Activity(intent); } } }