从一个App的某活动调用另一个App的某活动,
爆出异常:
java.lang.RuntimeException: Unable to destroy activity ...
java.lang.IllegalArgumentException : Receiver not regisered ...谁知道这是为什么?
需要注册活动?相关代码:
调用方:
Intent intent = new Intent("com.founder.apabi.BOOKREADING", encodePath(path));
//startActivity(intent);// 用这句就没异常。但是我想知道返回结果,所以要用下边的。
startActivityForResult(intent, 1);被调方:
<activity android:name="com.founder.apabi.reader.view.ReaderViewActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.founder.apabi.BOOKREADING" />
<data android:scheme="file"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> 活动返回时,调 setResult(200); // 正数负数均试过,都发生异常。发生异常在 调用方 onActivityResult之后。
爆出异常:
java.lang.RuntimeException: Unable to destroy activity ...
java.lang.IllegalArgumentException : Receiver not regisered ...谁知道这是为什么?
需要注册活动?相关代码:
调用方:
Intent intent = new Intent("com.founder.apabi.BOOKREADING", encodePath(path));
//startActivity(intent);// 用这句就没异常。但是我想知道返回结果,所以要用下边的。
startActivityForResult(intent, 1);被调方:
<activity android:name="com.founder.apabi.reader.view.ReaderViewActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.founder.apabi.BOOKREADING" />
<data android:scheme="file"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> 活动返回时,调 setResult(200); // 正数负数均试过,都发生异常。发生异常在 调用方 onActivityResult之后。
我试过跨app掉activity的,是引用android:name这个熟悉就可以了,应该是
Intent intent = new Intent("com.founder.apabi.reader.view.ReaderViewActivity", encodePath(path));
你的设置时需要这样Intent.addCatgory(android.name) 才行的,可以让你选多个匹配的。
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;public class Any extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String absolutePath = "/sdcard/apabireader/HowtoMake1.cebx";
String scheme = "file";
Intent intent = new Intent("com.founder.apabi.BOOKREADING", encodePath(scheme, absolutePath));
startActivity(intent);
}
private Uri encodePath(String scheme, String filePath) {
return Uri.parse(scheme + "://" + filePath);
}
}它的Manifest.xml,全部拷贝,如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.founder"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Any"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </application>
</manifest> 我没有用什么broadcast,receiver之类的。程序是在被调活动ReaderViewActivity里,我调用finish时发生异常的。
我想通过调用finish,结束被调活动,返回调用方活动。