SharedActivity.getIntent beyond OnCreate

  

I’m working on an Android project which is supposed to get a string from another application via shared activity.

If the application is not active, I’m able to get the getIntent info whether from the OnCreate or from a button click. But when the application is already launched and in background, if the other application send another intent, I get the same intent that was in the OnCreate and not the new one.

Thanks

Var
Intent: JIntent;
S: String;
begin

Try

Intent := SharedActivity.getIntent;

if Intent Nil Then
Begin

if TJIntent.JavaClass.ACTION_SEND.equals(intent.getAction) Then
Begin

S := JStringToString(intent.getStringExtra(TJIntent.JavaClass.EXTRA_TEXT));

End;

End;

Except
On E: Exception Do
ShowMessage(E.Message);
End;

Remy,

Thank you for your reply.

I tried everything (I think) and could’nt make it work. That’s what I did:

I followed Brian’s explanation by the letter, built a new .Jar file without the NFC calls and it failed at launch, that’s the log from DDMS:

05-13 11:46:49.101: E/AndroidRuntime(16597):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.blong.IntentTest/com.blong.nfc.NativeActivitySubclass}:
java.lang.ClassNotFoundException: Didn’t find class
“com.blong.nfc.NativeActivitySubclass” on path: DexPathList[[zip file
“/data/app/com.blong.IntentTest-1/base.apk”],nativeLibraryDirectories=[/data/app/com.blong.IntentTest-1/lib/arm,
/vendor/lib, /system/lib]]

So I rebuit the .Jar file from the original .Java file which includes the NFC and it didn’t work either. When the app is in background and launched from a new intent, the application shows a black screen and freezes as soon as it comes up, the last thing was to comment everything in the onNewIntent procedure and the result was the same – black screen.

Then I realized that the app was launched twice when having another app sending intent, and both instances freeze, see picture.

I tried also to add singletop to the launchmode as suggested in ci_ post – no success.

How can I make such a simple thing to work?

Thanks

Comments are closed.