Android Question Help: FLAG_IMMUTABLE or FLAG_MUTABLE

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi,

i get this error message when running on phone with android 13
on version 9 it works
i set targetsdk to 31
when reduce it to 30 it works on the new phone

my B4A version is 12

searching the forum i found some other posts on that topic and they were referred to use NB6 - here i got lost
i couldn't find any sample that works as all are either partial or used for services which i don't

i don't want to use sdk less than 31 as this is the recommendation now...

anyone can help ?
thanks
 
Solution
Last try - see if attached is working for "31". Have changed the Java code to be as follows:

B4X:
    NFCUtils(final Activity pActivity) {
        mActivity = pActivity;
        mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
        if (Build.VERSION.SDK_INT < 31) {
            mPendingIntent = PendingIntent.getActivity(mActivity, 0,
                    new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        } else {
       
            mPendingIntent = PendingIntent.getActivity(mActivity, 0,
                    new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 67108864);
        }  
    }

@agraham , please comment if I have it...

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
there is this post on the same issue


but i don't think it has anything to do with my app as the issue happens in the wrapped libs so my app has no control on that

am i right?
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
I think Johann has put the flag in the wrong place. It should replace the final parameter to getActivity which is still 0 in the jar.
firstly i'm not in position to even comment as i'm not that expert in such things
secondly i trust Johan to find and fix it as he wrote it and responded here to this call for help
i am now sitting tight holding my breath and waiting for his rescue :)
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Is that some kind of criticism of my comment? It's not welcome if it is!
Oh no, it's NOT
It's a statement on my position, I'm no expert and lucky me to admit it.
I do read your posts, replies etc - we're not a match
So sorry, his was and is not any kind of criticism, if it's anything it's an envying statement from my side...
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Last try - see if attached is working for "31". Have changed the Java code to be as follows:

B4X:
    NFCUtils(final Activity pActivity) {
        mActivity = pActivity;
        mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
        if (Build.VERSION.SDK_INT < 31) {
            mPendingIntent = PendingIntent.getActivity(mActivity, 0,
                    new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        } else {
        
            mPendingIntent = PendingIntent.getActivity(mActivity, 0,
                    new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 67108864);
        }   
    }

@agraham , please comment if I have it right/wrong - or if there is a better way to do it.
 

Attachments

  • TapCardImmutable2.zip
    128.7 KB · Views: 67
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Last try - see if attached is working for "31". Have changed the Java code to be as follows:

B4X:
    NFCUtils(final Activity pActivity) {
        mActivity = pActivity;
        mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
        if (Build.VERSION.SDK_INT < 31) {
            mPendingIntent = PendingIntent.getActivity(mActivity, 0,
                    new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        } else {
       
            mPendingIntent = PendingIntent.getActivity(mActivity, 0,
                    new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 67108864);
        }  
    }

@agraham , please comment if I have it right/wrong - or if there is a better way to do it.
dearest Johan
you should always declare "last try" even on first one as last try woeks like charm
this and the "other" shame on me that Agraham threw on my head as i found he was right from the beginning and i had a stupid error (still not telling - too ashamed)

so, to summarize - thank you, Agraham and all the others who came to my rescue to enable me to put together this really crazy project

one again thank you all !
 
Upvote 0
Solution

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Maybe one last question,
Johan - now the mechanism works 'independently' he fires the read every time a card is taped, is there a way to turn it on and off so it works only when the app is running or when I want it to?
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
There seems to be onPause and onResume methods in the library which you should be calling anyway. From the look of it you can call onPause any time you want to stop seeing card reads and onResume at any time you want to restart. Try it.
Thank you
I'm afraid I got lost here, just call the subs?
Parameters?
This is our of my abilities or knowledge
Any sample call will do much help and naturally I'll appreciate it...
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I'm afraid I got lost here, just call the subs?
They don't take parameters. You should be calling them in your activity's pause and resume events anyway but it looks like they just turn off and turn on the dispatch of card data events. Intellisense should show you how to call them.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
They don't take parameters. You should be calling them in your activity's pause and resume events anyway but it looks like they just turn off and turn on the dispatch of card data events. Intellisense should show you how to call them.
Thanks
I'll try it
And revert...
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
They don't take parameters. You should be calling them in your activity's pause and resume events anyway but it looks like they just turn off and turn on the dispatch of card data events. Intellisense should show you how to call them.
tried... failed...
as i said this is not my safe ground...

i tried to call _onPause (this is the only thing i found close to whgat you wrote - it is in the java code embedded in the b4a code (attached)
but i kept getting errors as it is nor declared
so once again "i'm lost"
can you please help?

how do i use these two functions?


B4X:
'these are hooks to the wrapper as the wrapper uses for eg onNewIntent, onResume, onPause and dont want to extend the wrapper with Activity
#If Java
    public void _onnewintent (android.content.Intent intent) {
    }

    public void _onresume () {
    }    
    
    public void _onpause () {
    }    

#End If
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
one more issue
the new app required a new RSA signature
as where the old existing one i use my old signature

when i set the signature in the new app to the new signature it changes the signature in the old app
so i understand there can be only one signature for all my apps or remember to change it for each one

if i now change the old app's signature and load it to google store - will it keep on as the original app as far as the store and users see it or it will be a "new" app ?
i need to keep it as the original so users will see it and get updates

thanks
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
how do i use these two functions?
You don't. You call them from B4X code as 'onPause' and 'onResume'. As I said above Intellisense should show you them to choose when you type the dot after your TapCard variable name.

I've no idea about signatures - I've never used the store.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
You don't. You call them from B4X code as 'onPause' and 'onResume'. As I said above Intellisense should show you them to choose when you type the dot after your TapCard variable name.

I've no idea about signatures - I've never used the store.
thanks

i couldn't find a way to call these functions as i get errors "not declared" - that's why i asked for any sample or further guidance

if you don't use the store - i wonder - how do you let your clients download & install ? and how do you overcome these warning by android about risk etc making the users to be hesitance and maybe walk away?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
i couldn't find a way to call these functions as i get errors "not declared"
I fail to understand the problem. They are methods declared in the library. Intellisense shows them. You just call them as normal.
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Dim Card As TapCard
End Sub

Sub Activity_Resume
    Card.onResume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    Card.onPause
End Sub

how do you let your clients download & install ?
I don't. I program only for myself and family nowadays.
 
Upvote 0
Top