本文介绍了传球意图不能获得额外的();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能让我的处主要活动记录已经在网页中我通过INTEN到另一个活动,但我无法得到的提取物。我怎样才能解决这个问题。

这是我的主要活动公共类ViewActivity延伸活动{

 私人的EditText mTextUserName;
私人的EditText mTextPassword;
公共字符串用户名;
公共字符串pass_word;

@覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);
    mTextUserName =(EditText上)findViewById(R.id.textUserName);
    mTextPassword =(EditText上)findViewById(R.id.textPassword);



    最终按钮mButtonLogin =(按钮)findViewById(R.id.buttonLogin);
    mButtonLogin.setOnClickListener(新View.OnClickListener(){
        公共无效的onClick(视图v){

            用户名= mTextUserName.getText()的toString()。
            pass_word = mTextPassword.getText()的toString()。

            意图goToNextActivity =新的意图(getApplicationContext(),ViewActivity.class);
            goToNextActivity.putExtra(用户名,用户名);
            goToNextActivity.putExtra(用户名,pass_word);

            startActivity(goToNextActivity);


        }
    });
 

在这里查看活动

 私人的WebView web视图;

公共无效的onCreate(包savedInstanceState){


    super.onCreate(savedInstanceState);
    的setContentView(R.layout.view);
    web视图=(web视图)findViewById(R.id.webView);
    。webView.getSettings()setUseWideViewPort(真正的);
    webView.setScrollbarFadingEnabled(假);
    webView.getSettings()setDefaultFontSize(20)。
    。webView.getSettings()setBuiltInZoomControls(真正的);
    webView.getSettings()setJavaScriptEnabled(真)。
    webView.setWebViewClient(新MyWebViewClient());




    webView.loadUrl(http://something.com);



}

私有类MyWebViewClient扩展WebViewClient {
    @覆盖
    公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL){
        view.loadUrl(URL);
        意图goToNextActivity =新的意图(getApplicationContext(),MainActivity.class);
        goToNextActivity.getExtras();
        返回true;

    }
}
 

这是加载一个网页,但没有登录

解决方案

 意图演员= getIntent()getExtras()。
字符串newString;
如果(临时演员== NULL){
    newString = NULL;
} 其他 {
    newString = extras.getString(用户名);
}
 

和两个值包含用户名和密码,您是给同样的键值......请改变和尝试。

Hi i can't get logged in already in a web page at mine main activity i passed inten to another activity but i can't get an extract. How can i solve it

this is mine main activitypublic class ViewActivity extends Activity {

private EditText mTextUserName;
private EditText mTextPassword;
public String user_name;
public String pass_word;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTextUserName = (EditText) findViewById(R.id.textUserName);
    mTextPassword = (EditText) findViewById(R.id.textPassword);



    final Button mButtonLogin = (Button) findViewById(R.id.buttonLogin);
    mButtonLogin.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            user_name = mTextUserName.getText().toString();
            pass_word = mTextPassword.getText().toString();

            Intent goToNextActivity = new Intent(getApplicationContext(), ViewActivity.class);
            goToNextActivity.putExtra("username", user_name);
            goToNextActivity.putExtra("username", pass_word);

            startActivity(goToNextActivity);


        }
    });

and here view activity

private WebView webView;

public void onCreate(Bundle savedInstanceState) {


    super.onCreate(savedInstanceState);
    setContentView(R.layout.view);
    webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setUseWideViewPort(true);
    webView.setScrollbarFadingEnabled(false);
    webView.getSettings().setDefaultFontSize(20);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new MyWebViewClient());




    webView.loadUrl("http://something.com");



}

private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        Intent goToNextActivity = new Intent(getApplicationContext(), MainActivity.class);
        goToNextActivity.getExtras();
        return true;

    }
}

it is loads a web page but not logged in

解决方案
Intent extras = getIntent().getExtras();
String newString;
if(extras == null) {
    newString= null;
} else {
    newString= extras.getString("username");
}

and for two values both username and password you are giving same key values...please change and try it.

这篇关于传球意图不能获得额外的();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 16:37