I need to call onHandleIntent and receive a value from app1 and get result in app2 without user notices ( different apps, one activity will call the servixe of other app). However, when onHandleIntent is starting in this line:
mReceiver = workIntent.getParcelableExtra("receiver");
Brings the error
E/Parcel: Class not found when unmarshalling: com.example.idscomercial.myapplication.AddressResultReceiver
java.lang.ClassNotFoundException: com.example.idscomercial.myapplication.AddressResultReceiver
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.idscomercial.myapplication.AddressResultReceiver" on path: DexPathList[[zip file "/data/app/com.veritran.vttokentest-2/base.apk"],nativeLibraryDirectories=[/data/app/com.veritran.vttokentest-2/lib/arm, /vendor/lib, /system/lib]]
I actually read :
https://stackoverflow.com/questions/28589509/android-e-parcel-class-not-found-when-unmarshalling-only-on-samsung-tab3
But still I cannot find the solution
This is the code:
App1
public class servicev extends IntentService {
protected ResultReceiver mReceiver;
public servicev() {
super("yeah");
}
@Override
protected void onHandleIntent(Intent workIntent) {
Toast b = Toast.makeText(this.getApplicationContext(), "onHandle starting", Toast.LENGTH_LONG );
b.show();
Log.d("just", "tellme");
String dataString = workIntent.getDataString();
mReceiver = workIntent.getParcelableExtra("receiver");
// mReceiver = new AddressResultReceiver(new Handler());
deliverResultToReceiver(1,"value of servicev");
}
private void deliverResultToReceiver(int resultCode, String message) {
Bundle bundle = new Bundle();
bundle.putString("receiver", message);
mReceiver.send(resultCode, bundle);
}
}
App2:
public class MainActivity extends AppCompatActivity {
protected ResultReceiver mResultReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startIntentService();
setContentView(R.layout.activity_main);
}
protected void startIntentService() {
//Intent intent = new Intent();
mResultReceiver = new AddressResultReceiver(new Handler());
Intent intent=new Intent("com.veritran.vttokentest.servicev.START_SERVICE");
intent.setPackage("com.veritran.vttokentest");
//Intent intent = new Intent(this, FetchAddressIntentService.class);
intent.putExtra("receiver", mResultReceiver);
startService(intent);
}
}
==> 2
public
class AddressResultReceiver extends ResultReceiver {
public AddressResultReceiver(Handler handler) {
super(handler);
}
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
int duration = Toast.LENGTH_LONG;
String mAddressOutput = resultData.getString("1");
//Toast toast = Toast.makeText(context, "hi brow", duration);
//toast.show();
if (resultCode == 1) {
}
}
}
Manifest app1:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.veritran.vttokentest">
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.veritran.vttokentest.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:enabled="true"
android:exported="true"
android:name="com.veritran.vttokentest.servicev">
<intent-filter>
<action android:name="com.veritran.vttokentest.servicev.START_SERVICE" />
</intent-filter>
</service>
</application>
</manifest>