English 中文(简体)
2. 从另一类中恢复意图价值
原标题:Retrieving the intent values from another class
  • 时间:2011-09-29 07:40:49
  •  标签:
  • android
  • json

我的问题是最基本的问题。 我一直在学习关于JAVA和roid的编码。 在此,我对如何描述我通过意图传播的价值观感到困惑。

In my first activity this is the intent that I am using.

            Intent intent = new Intent(MainActivity.this, Secondactivity.class);
            String regName1 = regName;
            intent.putExtra(regName1, regNameSplit[0]);
            startActivity(intent);

这里将包含三个价值观。 SessionID,URL,Name di by “-”。

我的第二次行动

public class Secondactivity extends Activity {
public final String TAG = "###---Secondactivity---###";
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.secondactivity);
    Log.i(TAG,"before if statement");
    if (getIntent().getStringExtra("regName1") != null){
        getIntent().getStringExtra("regName1").split("-");
        String[] str = "regName";
        Log.i(TAG, ""+str[0]+str[1]+str[2])
    iii
iii

iii

如果reg1总是无效的话,其价值就等于无效。

最佳回答

这一条

intent.putExtra(regName1, regNameSplit[0]);

相反,需要这样做。

intent.putExtra("regName1", regNameSplit[0]); // note the quotes

BUT 你们正在将格罗尼亚1作为一种变量加以使用......你们如何期望第二类人知道这一变量?

而是使用一种扼杀资源。

问题回答

and you are sure that the content of the variable regName is actually "regName"? cause you set the value using

intent.putExtra(regName, ... )

以及使用价值

intent.getStringExtra("regName")

1. 首次使用

专用

• 寻找地名;

just: intent.putExtra("regName1", regNameSplit[0]);

第二次活动

if (getIntent().getStringExtra("regName1") != null){ // }





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签