Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android twitter Uri意图正在变为null_Android_Twitter - Fatal编程技术网

Android twitter Uri意图正在变为null

Android twitter Uri意图正在变为null,android,twitter,Android,Twitter,当WebView重定向到Twitter\u活动时无法获取Uri 在登录按钮中单击 private void loginToTwitter() { new AsyncTask<Void, Void, Void>(){ @Override protected void onPreExecute() { super.onPreExecute(); pbr = new P

WebView
重定向到Twitter\u活动时无法获取Uri

登录按钮中
单击

private void loginToTwitter() {
        new AsyncTask<Void, Void, Void>(){
            @Override
            protected void onPreExecute() {
            super.onPreExecute();
                pbr =  new ProgressDialog(Twiiter_MainActivity.this);
                pbr.setMessage("Loding..");
                pbr.show();         
                checklogin = false;
            }

            @Override
            protected Void doInBackground(Void... params) {
                if (!isTwitterLoggedInAlready()) {
                    ConfigurationBuilder builder = new ConfigurationBuilder();
                    builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
                    builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
                    Configuration configuration = builder.build();
                    TwitterFactory factory = new TwitterFactory(configuration);
                    twitter = factory.getInstance();
                     try {
                        requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);                      
                        allReadynew  = true;
                    } catch (TwitterException e) {
                        e.printStackTrace();
                    }

                } else {
                    // user already logged into twitter                 

                     checklogin = true;
                }
                return null;
            }
            protected void onPostExecute(Void result) {
                    try {                                           
                     if(pbr!=null){
                         pbr.dismiss();
                     }
                     Twiiter_MainActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
                     } catch (Exception e) {
                     e.printStackTrace();                    
                     }              


            };
        }.execute();
    }

uri
Intent
获取
Null
,请帮助。

我会尝试重写这行:

Twiiter_MainActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
为此:

Intent intent = new Intent(CurrentActivity.this, targetActivity.class);
intent.setData(Uri.parse(requestToken.getAuthenticationURL());
startActivity(intent);

在没有看到其他同学的情况下,我不明白为什么要从
twiiter\u MainActivity调用
startActivity()
方法。这是,因为你似乎完全可以不用它。

在Wbview登录并返回之后,你是否发送了要在浏览器中处理的意图?当前意图应该会显示一个窗口,询问你要使用哪个应用来处理你的意图。因此,您无法获取意图,您需要使用意图直接调用其他活动。Like Intent Intent=new Intent(CurrentActivity.this,targetActivity.class)。不,您需要这样调用它。Intent Intent=new Intent(CurrentActivity.this,targetActivity.class),如我上面所说。但与TWITTER\u CALLBACK\u URL不匹配
Intent intent = new Intent(CurrentActivity.this, targetActivity.class);
intent.setData(Uri.parse(requestToken.getAuthenticationURL());
startActivity(intent);