怎样打开另一个app并传递一些参数过去?
app1
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.example.xeednfc");
Bundle bundle = new Bundle();
bundle.putString("user","1");
LaunchIntent.putExtras(bundle);
startActivity(LaunchIntent);app2protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Bundle bunde = getIntent().getExtras();
怎么bundle 一直是空的。接收不到
if(bunde!=null)
{
bundle.getString("user");}
}
app1
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.example.xeednfc");
Bundle bundle = new Bundle();
bundle.putString("user","1");
LaunchIntent.putExtras(bundle);
startActivity(LaunchIntent);app2protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Bundle bunde = getIntent().getExtras();
怎么bundle 一直是空的。接收不到
if(bunde!=null)
{
bundle.getString("user");}
}
在第一个app里Intent intent = new Intent("com.ox.lyq.ABCD");
intent.putExtra("abcd", "ABCD");
startActivity(Intent.createChooser(intent, "ABCD"));
在第二个app的AndroidManifest.xml里
<activity android:name="BActivity" >
<intent-filter>
<action android:name="com.ox.lyq.ABCD" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<category android:name="android.intent.category.DEFAULT" />
不可少
在这个activity里textView = (TextView) findViewById(R.id.textView1);
Intent intent = getIntent();
if (intent != null) {
String str = intent.getStringExtra("abcd");
textView.setText(str);
}
这绝对是2个app