Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
为什么oauth中的回调url没有将我重定向到android中的onResume()?_Android_Url_Oauth_Callback_Onresume - Fatal编程技术网

为什么oauth中的回调url没有将我重定向到android中的onResume()?

为什么oauth中的回调url没有将我重定向到android中的onResume()?,android,url,oauth,callback,onresume,Android,Url,Oauth,Callback,Onresume,我需要您的帮助,以找出为什么回调url不能与我一起工作,因为我无法返回到活动中的onResume 这是我使用的代码 public class OAuthTrialsActivity extends Activity { /** Called when the activity is first created. */ private static final String CONSUMER_KEY = "66aba0d1168566c364d86e6087

我需要您的帮助,以找出为什么回调url不能与我一起工作,因为我无法返回到活动中的onResume

这是我使用的代码

    public class OAuthTrialsActivity extends Activity {
        /** Called when the activity is first created. */
        private static final String CONSUMER_KEY = "66aba0d1168566c364d86e6087bea04e04e9ff754";
        private static final String CONSUMER_SECRET = "aec138c913cb21763b4983de77683a04";
        private static final int CALL_BACK = 1;

        private static String ACCESS_KEY = null;
        private static String ACCESS_SECRET = null;


        private static final String REQUEST_URL = "http://yakhabar.tawasoldev.com/index.php/api/requestToken";
        private static final String ACCESS_TOKEN_URL = "http://yakhabar.tawasoldev.com//index.php/api/accessToken";
        private static final String AUTH_URL = "http://yakhabar.tawasoldev.com/index.php/api/AuthorizeApp";
        private static final String CALLBACK_URL = "http://localhost/app.php?third=true";

        private static CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(
                    CONSUMER_KEY, CONSUMER_SECRET);
        private static CommonsHttpOAuthProvider provider = new CommonsHttpOAuthProvider(
        REQUEST_URL, ACCESS_TOKEN_URL, AUTH_URL); 


        Button btnLogin;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            provider.setOAuth10a(true);
            btnLogin = (Button) findViewById(R.id.btnLogin);
            btnLogin.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                try {
                        String authURL = provider.retrieveRequestToken(
                                            consumer, CALLBACK_URL);

                    Log.d("OAuthTwitter authURL", authURL);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri
                                            .parse(authURL)));


                } catch (OAuthMessageSignerException e) {
                e.printStackTrace();
                } catch (OAuthNotAuthorizedException e) {
                e.printStackTrace();
                } catch (OAuthExpectationFailedException e) {
                e.printStackTrace();
                } catch (OAuthCommunicationException e) {
                e.printStackTrace();
                }
              }
            });
        }
 @Override
    public void onResume() {
        super.onResume();
        Uri uri = this.getIntent().getData();
        Log.d("ana shoftha","ahmed"+uri);
        if (uri != null && uri.toString().startsWith(CALLBACK_URL)) {
            Log.d("ana shoftha","ahmed");
            Log.d("OAuthTwitter uri", uri.toString());
            String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER);
            Log.d("OAuthTwitter verifier", verifier);
            try {

                provider.retrieveAccessToken(consumer, verifier);
                ACCESS_KEY = consumer.getToken();
                ACCESS_SECRET = consumer.getTokenSecret();

                Log.d("OAuthTwitter key ", ACCESS_KEY);
                Log.d("OAuthTwitter secret", ACCESS_SECRET);

            } catch (OAuthMessageSignerException e) {
                e.printStackTrace();
            } catch (OAuthNotAuthorizedException e) {
                e.printStackTrace();
            } catch (OAuthExpectationFailedException e) {
                e.printStackTrace();
            } catch (OAuthCommunicationException e) {
                e.printStackTrace();
            }
        }
    }
}
这是舱单

<activity android:name=".OAuthTrialsActivity" android:label="@string/app_name"
            >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="localhost" />
            </intent-filter>
        </activity>

该服务使用验证器将我指向回调url,但我可以提取它,因为我不返回活动


谁能帮我一个忙,给我一个解决方案吗?

我今天遇到了同样的问题。在Twitter上,我没有在设置页面上指定回调URL。在我添加我的onReceive开始工作之后。url可以是任何内容,而不是特定于您的应用程序。希望这有帮助

你在安卓ICS上也查过吗