Android Question Open Email app

kohle

Active Member
Licensed User
Longtime User
Hi,

i open the email app with this code.
I think, the first time I get a dialog to choose the app.
I selected the notes app.
Now it always open the notes app.
First, how can I prefend this dialog . It should open always gmail.
Second how can I change back via script , without deinstall .



B4X:
Dim msg As Email

    subject=en.desc_plaintext & " - " & en.Title
  
    msg.Subject=subject
    msg.Body= gl_BODY
    msg.To.Add(gl_EMAIL)
  
    StartActivity(msg.GetIntent)
 

DonManfred

Expert
Licensed User
Longtime User
Now it always open the notes app.
First, how can I prefend this dialog . It should open always gmail.
Second how can I change back via script , without deinstall .
You can set the default apps in the settings of your device.
 
Upvote 0

kohle

Active Member
Licensed User
Longtime User
I know this, but the users are no programmers, maybe old people. When they quickly choose the wrong app ....
So is there no way to say open gmail ...., nothing else ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
When they quickly choose the wrong app ....
You can create a tutorial for your users and send them a link to the tut....
So is there no way to say open gmail
You can check the GMail packagename and start the app manually. But i dont know how to define the intent to send a mail in this case.

But i dont know a way to change the setting the user used. You can not change the setting programmatically.
 
Upvote 0

kohle

Active Member
Licensed User
Longtime User
one option is like the code, but it always open the dialog to choose :(

B4X:
Dim msg As Email

    subject=en.desc_plaintext & " - " & en.Title
   
    msg.Subject=subject
    msg.Body= gl_BODY
    msg.To.Add(gl_EMAIL)
   
    Dim i As Intent
    i = msg.GetIntent
    i.SetComponent("android/com.android.internal.app.ResolverActivity")
       
   
    StartActivity(i)
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
B4X:
Dim msg As Email
Dim intent1 As Intent

msg.Subject="subject"
    msg.Body= "body"
    msg.To.Add("[email protected]")


 
intent1 = msg.GetIntent
    intent1.SetComponent("com.google.android.gm/.ComposeActivityGmail")

    StartActivity(intent1)

choose from here
B4X:
Dim pm As PackageManager

For Each em As String In pm.QueryIntentActivities(msg.getintent)
     
        Log(em)
    Next
 
Last edited:
Upvote 0

kohle

Active Member
Licensed User
Longtime User
B4X:
Dim msg As Email
Dim intent1 As Intent

msg.Subject="subject"
    msg.Body= "body"
    msg.To.Add("[email protected]")



intent1 = msg.GetIntent
    intent1.SetComponent("com.google.android.gm/.ComposeActivityGmail")

    StartActivity(intent1)

choose from here
B4X:
Dim pm As PackageManager

For Each em As String In pm.QueryIntentActivities(msg.getintent)
    
        Log(em)
    Next



This give an error :
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SEND_MULTIPLE typ=text/plain flg=0x20000 cmp=com.google.android.gm/.ComposeActivityGmail (has extras) } from ProcessRecord{eac19be 24238:jk.rt_calendar/u0a202} (pid=24238, uid=10202) not exported from uid 10092
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
can you post you project(or create small project) ? il try it on my device

i guess your device is 6.0 and up

edit:
try this
B4X:
  intent1.SetComponent("com.google.android.gm/.info.activityInfo.name")
 
Last edited:
Upvote 0

kohle

Active Member
Licensed User
Longtime User
yes my device is 6.0.1.

It works with :
i.SetComponent("com.google.android.gm/.ComposeActivityGmailExternal")
insteed of
"com.google.android.gm/.ComposeActivityGmail"

But will it work on all device >= Android 4 ?
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
But will it work on all device >= Android 4 ?

tested on my device 4.4 & 4.2
didnt work ..

just use this code to see the right intent for different android version
B4X:
Dim pm As PackageManager

For Each em As String In pm.QueryIntentActivities(msg.getintent)
    
        Log(em)
    Next
 
Last edited:
Upvote 0
Top