相关疑难解决方法(0)

不调用onNewIntent

我的情况很奇怪.
有一个应用程序,我决定从第一个应用程序的代码创建另一个.
我复制了.xml文件,复制了.java文件以便一切正常.
但是有一个巨大的问题:我的onNewIntent(Intent intent)方法是在第一个项目中调用的,但它没有在第二个项目中调用(代码是相同的!)

方法,可以触发,但现在无法触发

public void onClick(View arg0) {
    Intent browserInt = new Intent (Intent.ACTION_VIEW, 
    Uri.parse("https://oauth.yandex.ru/authorize?response_type=token&client_id=zzzzz"));
    browserInt.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(browserInt);
}
Run Code Online (Sandbox Code Playgroud)

这是onNewIntent()方法:

@Override
protected void onNewIntent(Intent intent){
    System.out.println(" I WORKED!");
    Uri uri = intent.getData();
    if (uri!=null) {
        String m = uri.toString().split("#")[1];
        String[] args = m.split("&");
        String arg = args[0];
        String token = arg.split("=")[1];
        System.out.println(token);
    }   
}
Run Code Online (Sandbox Code Playgroud)

遗憾的是,我在日志中看不到"我工作".
我在SO和Internet上都阅读了很多类似的问题,尝试设置Intent标志SINGLE_TOP,SINGLE_TASK等等.

这是Android Manifest的WORKING项目:

<application 
    android:name="yyy"
    android:icon="@drawable/yaru_icon"
    android:allowBackup="false"
    android:label="xxx"
    android:theme="@style/LightTheme">

    <activity
        android:name=".Main"
        android:label="xxx"
        android:launchMode="singleTask">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application> …
Run Code Online (Sandbox Code Playgroud)

android android-intent

29
推荐指数
3
解决办法
3万
查看次数

标签 统计

android ×1

android-intent ×1