怎样打开另一个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");}
}
解决方案 »
- 求教,关于android游戏场景缩放和拖动功能实现
- 怎么查看 android 应用程序内存使用情况
- 收藏的一些关于Android UI的项目
- 点击ListView时ListView.setOnItemLongClickListener()消息不响应?
- 手机休眠状态下,alarmmanager不准的问题
- 能告诉我如果实现让系统音乐播放器暂停吗?
- sdl在android实体机上显示不出来窗口,只有一个单色的全屏
- Android图片扫描
- 收藏功能
- 使用腾讯官方SDK实现第三方登录,在调用Tencent.login后是否会自动判断已经有qq客户端?是否能设置使用网页版登录?
- Android HOME键唤醒屏幕
- 不能自动写入R.java
在第一个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