Android Question Widget running another service via a menu

SueHale

Member
Licensed User
Longtime User
Hi All,

Having a problem with launching the GCM Push example service from a Menu. The menu is entered from a Widget by tapping the panel.

The options in the Menu activity are all fine except the calling of the push service module.

This is the code have used from the Menu to try and attach this service once a user enters a name and presses the register button.

B4X:
Sub btnRegister_Click
    If Regex.IsMatch("[\d\w]+", txtName.Text) = False Then
        ToastMessageShow("Name not valid", True)
        Return
    End If
    Register(txtName.Text)
End Sub
 
Sub Register(Name As String)
    PushService.DeviceName = Name
    CallSubDelayed2(PushService, "RegisterDevice", False)
End Sub
 
Sub Unregister(Name As String)
    PushService.DeviceName = Name
    CallSubDelayed2(PushService, "RegisterDevice", True)
End Sub

The service is never registered and the Widget just stops. As a standalone APP this works as expected.
The Widget is a very basic barebones example.

Sorry that this evening not at the PC with the complete project on so as to generate an export of the project. Now just curious if anyone else has had a similar issue. Of course this is not the best way to ask for help...

Thank-you
Sue.
 

SueHale

Member
Licensed User
Longtime User
Hi Erel,

Thank-you for your advice. I can only get logs with the Filter off and this is the result: -

B4X:
GC_CONCURRENT freed 443K, 15% free 9723K/11335K, paused 4ms+7ms, total 38ms
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:anywheresoftware.b4a.samples.DATVNOTIFY
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
Failed to destroy process 15065
libcore.io.ErrnoException: kill failed: ESRCH (No such process)
    at libcore.io.Posix.kill(Native Method)
    at libcore.io.ForwardingOs.kill(ForwardingOs.java:77)
    at java.lang.ProcessManager$ProcessImpl.destroy(ProcessManager.java:260)
    at anywheresoftware.b4a.phone.Phone$LogCat.LogCatStop(Phone.java:759)
    at anywheresoftware.b4a.b4abridge.service1._stoplogcat(service1.java:612)
    at anywheresoftware.b4a.b4abridge.service1._streams_newdata(service1.java:673)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA$3.run(BA.java:307)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4856)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
    at dalvik.system.NativeStart.main(Native Method)
Failed to destroy process 15065
libcore.io.ErrnoException: kill failed: ESRCH (No such process)
    at libcore.io.Posix.kill(Native Method)
    at libcore.io.ForwardingOs.kill(ForwardingOs.java:77)
    at java.lang.ProcessManager$ProcessImpl.destroy(ProcessManager.java:260)
    at anywheresoftware.b4a.phone.Phone$LogCat.LogCatStop(Phone.java:759)
    at anywheresoftware.b4a.phone.Phone$LogCat.LogCatStart(Phone.java:704)
    at anywheresoftware.b4a.b4abridge.service1._startlogcat(service1.java:605)
    at anywheresoftware.b4a.b4abridge.service1._streams_newdata(service1.java:669)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA$3.run(BA.java:307)

With best wishes
Sue.
 
Upvote 0

SueHale

Member
Licensed User
Longtime User
Hi Erel,

Thought should just update to let you know why Push was not working via my menu.
I forgot to add the permissions to the Manifest File from your sample project :)

B4X:
'C2DM Permissions
AddManifestText(<permission android:name="$PACKAGE$.permission.C2D_MESSAGE" android:protectionLevel="signature" />)
AddPermission($PACKAGE$.permission.C2D_MESSAGE)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
' Push Service Receiver Attribute
SetReceiverAttribute(PushService, android:permission, "com.google.android.c2dm.permission.SEND")
' Service Receiver Text
AddReceiverText(PushService,
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="$PACKAGE$" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="$PACKAGE$" />
</intent-filter>)

I know you would have had this resolved within a minute if I had attached the project. Thank-you for providing such excellent support.

With best wishes
Sue.
 
Upvote 0
Top