标签: extras

putExtras多个putString不起作用

我需要将2个变量从一个活动传递到另一个活动.

第一项活动我有以下内容:

@Override 
public boolean onContextItemSelected(MenuItem item) { 
    Bundle bundle=new Bundle();
switch (item.getItemId()){ 

case 1: 

    bundle.putString(drinkButton, "4");
    bundle.putString(drinkType, "1");
    Intent myIntent1 = new Intent(this, DrinksList.class);
    myIntent1.putExtras(bundle);
    startActivityForResult(myIntent1, 0);
    return true;

case 2: 

    bundle.putString(drinkButton, "1");
    bundle.putString(drinkType, "2");
    Intent myIntent2 = new Intent(this, DrinksList.class);
    myIntent2.putExtras(bundle);
    startActivityForResult(myIntent2, 0);
    return true;
}
return false;
Run Code Online (Sandbox Code Playgroud)

然后在第二个活动中我使用它来获取值,但两个值都是相同的,即与'drinkType'相同的情况1我得到"1"两个和情况2我得到"2"两个我期望得到4,1和1,2.

Bundle extras = getIntent().getExtras();

        drinkButton = extras.getString(drinkButton);


        drinkType = extras.getString(drinkType);

    Toast.makeText(this, "drink Button = "+drinkButton+"  Drink Type = "+drinkType, Toast.LENGTH_LONG).show();  


} 
Run Code Online (Sandbox Code Playgroud)

看来我不能超过一个额外的.有任何想法吗?

eclipse android extras

2
推荐指数
1
解决办法
4433
查看次数

在Cordova应用程序中获得更多功能

我们有两个Android应用程序:一个使用本机Java实现,另一个使用Ionic编写。Ionic应用程序使用lampaa插件启动我的应用程序,即Android应用程序。我可以使用以下代码接收Ionic应用提供的额外功能:

String keyid = getIntent().getStringExtra("keyid");
Run Code Online (Sandbox Code Playgroud)

在退出我的应用程序之前,我想将其他内容发送到Ionic应用程序。从Android方面很容易做到这一点。Ionic应用程序如何知道我的应用程序已将控制权转移给它,它如何检索我已发送的附加内容?

android extras cordova

2
推荐指数
1
解决办法
2863
查看次数

android:从 Intent extras 中获得相同的值

我这样做是为了创建一个意图。

Intent notificationIntent = new Intent(this, Startup.class);
notificationIntent.putExtra("url", contentUrl);

PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
Run Code Online (Sandbox Code Playgroud)

得到额外的钱后,

CharSequence url = this.getIntent().getCharSequenceExtra("url");
Run Code Online (Sandbox Code Playgroud)

有许多 Intent 及其各自的 url 值。但我也在 Startup 类的 onCreate() 中得到了相同的值。

我做错了什么?

android bundle extras android-intent

0
推荐指数
1
解决办法
3655
查看次数

Android什么是Preference.getExtras()用于?

Preference类有一个名为getExtras()的方法.
它可能或可能与Preference意图无关,但Extras可以直接使用intent获取和放置.
在Preference类中没有putExtra/s()方法,那么...
getExtras()的目的是什么?使用哪种情景剧?

android preference extras android-intent

0
推荐指数
1
解决办法
573
查看次数

标签 统计

android ×4

extras ×4

android-intent ×2

bundle ×1

cordova ×1

eclipse ×1

preference ×1