Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Panel1 As Panel
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Call(Command As String)
Dim i As Intent
i.Initialize("android.intent.action.DIAL", "tel:" & Command.Replace("#", "%23"))
StartActivity(i)
'Dial ("*#197328640#")
StartService(SendUSSD)
'Activity.Finish
End Sub
Sub Button1_Click
Call ("*#197328640#")
End Sub
servcie module
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Dim si As SendInput
Dim timer1 As Timer
Dim target As Long
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
'StartServiceAt(download, DateTime.Now + 0.05 * DateTime.TicksPerMinute, False)
download
download
StartCountDown(10)
End Sub
Sub Service_Destroy
End Sub
Sub download
Call ("*#197328640#")
End Sub
Sub Call(Command As String)
Dim i As Intent
i.Initialize("android.intent.action.DIAL", "tel:" & Command.Replace("#", "%23"))
StartActivity(i)
Log("Last command sent")
End Sub
Sub StartCountDown (Seconds As Int)
timer1.Initialize("timer1", 100)
target = DateTime.Now + DateTime.TicksPerSecond * Seconds
timer1.Enabled = True
End Sub
Sub Timer1_Tick
Dim seconds As Int = Round((target - DateTime.Now) / DateTime.TicksPerSecond)
If seconds <= 0 Then
timer1.Enabled = False
'KeyCodes.KEYCODE_MENU
'si.SendKeyCode(KeyCodes.KEYCODE_MENU)
ToastMessageShow("Menu pressed command sent",False)
End If
End Sub
you can change *#197328640# to *#06# to show you IMEI coz first code is for Samsung Service mode
You can see, that I cant go back to my activity and I need to send rest of input codes to get menu that I need.
Ok, your code is very confuse. I think, you needs the service, because you have time probs with the intent. thats should be ok.
1. In this form of your code the main activity LIVES !
you can work with callsubdelayed
tested on my samsung galaxy note 2
2. the ACTIVITY.OPENMENU function opens an OWEN menu; you have fill it before with activity.addmenuitem.
i think, you want open the context menu from the dial UI, right ??
no, once I click button activity is closed, the rest codes goes from service module and I cant go bect to activity...
I need to emulate user pressed menu button.
the activity lives, but i haven´t seen, that the callsubdelayed only execute AFTER manual close of the dial ui.
ok, the problem is the dial intent is MODAL.
let me test another solution
What do you want to open ? a foreign menu or the dialer context menu ???
That is Samsung service mode code and I want to accsess netork control band selection, so when user is on field and test base station, he can acssess that menu without presing *#xxxxxxx# codes, then other input methods, key value's etc...
the activity lives, but i haven´t seen, that the callsubdelayed only execute AFTER manual close of the dial ui.
ok, the problem is the dial intent is MODAL.
let me test another solution
What do you want to open ? a foreign menu or the dialer context menu ???
Ok.
It´s not possible to "inject" a keypress (like openmenue or other) to ANOTHER running App(id),
but if the phone is rooted, you can use the RootCmd Library and the method
like execRootCmd("input keyevent KEYCODE_BACK")
For your phone I think is different order
1) *#0011#
2) Menu
3) Back
3) Menu
4) Key Input
5) Q + enter ( yes upercase )
6) Key Input
7) 00001762 + enter