*

インテント

公開日: : 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】DrawableとBitmap、リソースの相互変換 

Resource → Bitmap Bitmap bm = BitmapFactory.dec

記事を読む

no image

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

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

記事を読む

no image

【android】任意のスレッドで処理を行う

非UIスレッドでUIを操作したい場合に、任意の処理をUIスレッド上で実行する。 目次

記事を読む

no image

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

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

記事を読む

no image

アプリ間連携 Intentfiler

ブラウザの共有からURLを受け取る。 Manifest.xmlのURL受け取り先のactivity

記事を読む

no image

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

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

記事を読む

no image

【android】 APIバージョンによる動作の違い

「最近使用したアプリケーション」からの起動 2.x系 -> onNewIntentが呼ばれる 4

記事を読む

no image

【android】複数のカスタムテーマを設定で切り替える

背景色やアプリ全体のテーマ色を設定で変更したいという要望をもらったので実装してみました。

記事を読む

no image

【android】リスト項目のmatch_parentが効かない

下記のようなリスト項目用のレイアウトを用意して、リストの右端にチェックボックスを置くようにしたのです

記事を読む

no image

【android】ネットワークの接続状況を確認する

コードから接続状況を確認。 ConnectivityManager co

記事を読む

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 ↑