1
2
|
Intent i =
new
Intent(
this
,AnotherActivity.
class
);
startActivity(i);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import
android.app.Activity;
import
android.content.Intent;
import
android.net.Uri;
import
android.os.Bundle;
public
class
Main
extends
Activity {
private
final
String mapSearchIntent =
"com.decarta.mapsearch.intent.action.SEARCH"
;
/** Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
Uri mapUri = Uri.parse(
"geo:39.906033,116.397700"
);
Intent i =
new
Intent(mapSearchIntent, mapUri);
i.setData(mapUri);
startActivity(i);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import
android.app.Activity;
import
android.content.Intent;
import
android.net.Uri;
import
android.os.Bundle;
/**
* @author Tony Shen
*/
public
class
SecondActivity
extends
Activity{
private
Uri data;
private
String action;
/** Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
Intent intent = getIntent();
if
(intent.getAction() !=
null
)
action = intent.getAction();
if
(intent.getData()!=
null
)
data = intent.getData();
if
(action.equals(
"com.decarta.mapsearch.intent.action.SEARCH"
)) {
Intent i =
new
Intent(Intent.ACTION_VIEW, data);
startActivity(i);
}
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<
application
android:icon
=
"@drawable/icon"
android:label
=
"@string/app_name"
>
<
activity
android:name
=
".Main"
android:label
=
"@string/app_name"
>
<
intent-filter
>
<
action
android:name
=
"android.intent.action.MAIN"
/>
<
category
android:name
=
"android.intent.category.LAUNCHER"
/>
intent-filter
>
activity
>
<
activity
android:name
=
".SecondActivity"
>
<
intent-filter
>
<
action
android:name
=
"com.decarta.mapsearch.intent.action.SEARCH"
/>
<
category
android:name
=
"android.intent.category.DEFAULT"
/>
<
data
android:scheme
=
"geo"
/>
intent-filter
>
activity
>
application
>
<
application
android:icon
=
"@drawable/icon"
android:label
=
"@string/app_name"
>
<
activity
android:name
=
".Main"
android:label
=
"@string/app_name"
>
<
intent-filter
>
<
action
android:name
=
"android.intent.action.MAIN"
/>
<
category
android:name
=
"android.intent.category.LAUNCHER"
/>
intent-filter
>
activity
>
<
activity
android:name
=
".SecondActivity"
>
<
intent-filter
>
<
action
android:name
=
"com.decarta.mapsearch.intent.action.SEARCH"
/>
<
category
android:name
=
"android.intent.category.DEFAULT"
/>
<
data
android:scheme
=
"geo"
/>
intent-filter
>
activity
>
application
>
|