buongiorno a tutti, vorrei creare una app che una volta avviata avvii un servizio sempre in ascolto magari che visualizza un icona nella barra di stato in alto
quando ricevo un sms, se questo sms contiene la stringa "123" allora chiamo una Sub di nome MieiComandi in cui
1 riaccendo lo schermo
2 avvio una app di nome "miaApp"
ho provato a cercare di capire l'esempio al link qui sotto ma non riesco a utilizzarlo per il mio scopo, qualcuno può darmi qualche aiuto? Grazie.
	
	
		
			
			
				
					
						
							 www.b4x.com
						
					
					www.b4x.com
				
			
		
	
qui sotto vi riporto il codice inserito in manifest e il codice inserito nel modulo servizio "Starter"
Codice Manifest
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Codice Servizio Starter
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			quando ricevo un sms, se questo sms contiene la stringa "123" allora chiamo una Sub di nome MieiComandi in cui
1 riaccendo lo schermo
2 avvio una app di nome "miaApp"
ho provato a cercare di capire l'esempio al link qui sotto ma non riesco a utilizzarlo per il mio scopo, qualcuno può darmi qualche aiuto? Grazie.
Intent Filters - Intercepting SMS messages in the background
Old tutorial. Don't use services. Use receivers. Broadcast receivers are program components that can handle broadcasted messages. These messages usually notify about a system event.  There are two types of receivers in Android: statically registered receivers and dynamically registered...
				 www.b4x.com
						
					
					www.b4x.com
				qui sotto vi riporto il codice inserito in manifest e il codice inserito nel modulo servizio "Starter"
Codice Manifest
			
				B4X:
			
		
		
		AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(Starter,
<intent-filter>
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)Codice Servizio Starter
			
				B4X:
			
		
		
		#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Type Message (Address As String, Body As String)
    Dim Notification1 As Notification
End Sub
Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    Notification1.Initialize
    Notification1.Icon = "restart1.png" 'use the application icon file for the notification
    Notification1.Vibrate = False
End Sub
Sub Service_Start (StartingIntent As Intent)
    Notification1.SetInfo("Ricezione SMS", "Downloading: ", Main)
    Service.StartForeground(1, Notification1)
    If StartingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
        Dim messages() As Message
        messages = ParseSmsIntent(StartingIntent)
        For i = 0 To messages.Length - 1
            Log(messages(i))
        Next
        ToastMessageShow("message received" & messages, True)
    End If
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one) cases.
End Sub
Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
Sub Service_Destroy
End Sub
Sub ParseSmsIntent (in As Intent) As Message()
    Dim messages() As Message
    If in.HasExtra("pdus") = False Then Return messages
    Dim pdus() As Object
    Dim r As Reflector
    pdus = in.GetExtra("pdus")
    If pdus.Length > 0 Then
        Dim messages(pdus.Length) As Message
        For i = 0 To pdus.Length - 1
            r.Target = r.RunStaticMethod("android.telephony.SmsMessage", "createFromPdu", _
            Array As Object(pdus(i)), Array As String("[B"))
            messages(i).Body = r.RunMethod("getMessageBody")
            messages(i).Address = r.RunMethod("getOriginatingAddress")
        Next
    End If
    Return messages
End Sub 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		