最終更新:
moonlight_aska 2011年07月23日(土) 18:30:44履歴
ランチャーアクティビティ(LauncherActivity)は, 指定したインテントを扱えるアクティビティの一覧に表示する.

Googleマップを選択すると, 指定した場所の地図が表示される.


- res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawSelectorOnTop="false"
/>
</LinearLayout>
- Launcher01.java
- アクティビティは, LauncherActivityクラスを継承する.
- getTargetIntentメソッドをオーバーライドして実装し, 戻り値としてインテントのインスタンスを返す.
- インテントのURIに, 下記のようなURIを指定する.
Uri | 対象 | 例 |
http://web_address | ブラウザ | http://www.google.com |
tel:phone_number | 電話 | tel:080-0001-0001 |
content://contacts/people | 連絡先 | content://contacts/people/ |
geo:latitude,longitude | 地図 | geo:0,0?q=Osaka |
package com.moonlight_aska.android.launcher01;
import android.app.LauncherActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
public class Launcher01 extends LauncherActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected Intent getTargetIntent() {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=Osaka"));
return intent;
}
}
Googleマップを選択すると, 指定した場所の地図が表示される.

コメントをかく