*

インテント

公開日: : android

基本

    //任意のアクティビティの起動
    Intent intent = new Intent(MultiSerch.this,ListBookMark.class);// インテントの作成
    startActivity(intent);// アクティビティの開始

	//呼び出すアクティビティにデータを渡す
	Intent intent = new Intent();
	intent.putExtra("key", "value");

	//呼び出し元intentから渡されたデータを取得
	Bundle extras = getIntent().getExtras();
	String taskName = extras.getString("taskName");
	//データがオブジェクトの場合
	StoreData data = (StoreData)intent.getSerializableExtra("StoreData");

	//呼び出し元にデータを送る
	Intent intent = new Intent();
	intent.putExtra("keyword", "value");
	setResult(RESULT_OK, intent);


標準機能との連携

    //マーケットを起動
    Uri uri = Uri.parse("market://details?id=" + packageName);
    Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri);
    ((Activity)context).startActivity(marketIntent);

	//ブラウザを起動
	Intent intent = new Intent();
	intent.setAction(Intent.ACTION_VIEW);
	intent.setData(Uri.parse(uriString));
	startActivity(intent);

	//マップを起動
	Intent intent = new Intent();
	intent.setAction(Intent.ACTION_VIEW);
	intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
	//検索
	intent.setData(Uri.parse("http://maps.google.com/maps?q=東京"));
	//経路 dirflg=d|t|w : 車|電車|徒歩
	intent.setData(Uri.parse("http://maps.google.com/maps?saddr=35.671989,139.763965&daddr=35.671989,139.7&dirflg=w"));
	//地点
	intent.setData(Uri.parse("http://maps.google.com/maps?q=35.616209,140.114307(目的地)"));

	startActivity(intent);


	//マップを起動2
	Intent intent = new Intent();
	intent.setAction(Intent.ACTION_VIEW);
	//検索
	intent.setData(Uri.parse("geo:0,0?q=鳥貴族 新宿"));
	//地点
	intent.setData(Uri.parse("geo:35.671989,139.763965?z=1"));
	startActivity(intent);

関連記事

no image

【android】処理時間を計測する

パフォーマンスのリファクタリングを行うには処理時間の計測がかかせません。 SDK標準のクラスを使っ

記事を読む

no image

【android】ハードウェアキー入力を検出する

Activityを継承したクラスで下記を記述します。 public boolean

記事を読む

no image

【android】アニメーション

Viewにアニメーションを付加する方法です。 目次 アニメーションの実行 de

記事を読む

no image

【android】 setOnClickListener(false)が効かない

間違いその1 OnClickListenerが登録されているViewにsetClickable

記事を読む

no image

【android】webviewでアプリ内にwebページを読み込む

webviewを使ってandroidアプリ内にwebページを読み込む定型文です。 //vie

記事を読む

no image

[android] モンキーテスト(Monkey Test)を実行する

最近テストの効率化に目覚めました。 モンキーテストは猿にアプリを渡してみてめちゃくちゃな操作をさせ

記事を読む

no image

【andoid】ViewPagerを使う

1. layout.xmlにViewPagerを配置  2. PagerAdapter.jav

記事を読む

no image

【android】アプリのバージョン情報を取得する

int versionCode = -1; String versionName = &quo

記事を読む

no image

【android】 Android4.1のserviceでdefaultPreferenceがおかしい

【現象】 ActivityでdefaultPreferencesで保存したデータがservice内

記事を読む

no image

【android】バイブレーションを使う

必要なファイル MyApp.manifest MyApp.java MyApp.m

記事を読む

Message

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

no image
知らないと損をする6つのライセンスまとめ

オープンソースやフリーウェア、フリー素材などが巷に溢れ、それらを利用す

no image
ガリレオ:ニュースブラウザをリリースしました。

概要 ガリレオはニュースを読んだり、検索する機能に特化したブラウザア

no image
【android】Activityとプロセスのライフサイクル

またもやライフサイクル周りでハマったのですが、Androidのライフサ

→もっと見る

PAGE TOP ↑