PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Android and BroadcastReceiver revisited
Android and BroadcastReceiver revisited
Débuté par Meidell, 27 mar. 2018 09:59 - Aucune réponse
Membre enregistré
15 messages
Posté le 27 mars 2018 - 09:59
Hi, the java code below should show a toast when somebody calls on the phone and is integrated as a method in windev mobile 22 and compiles fine. However when the app starts on the phone it throws the following error message "permission denial: not allowed to send broadcast android.intent.action.PHONE_STATE from...)

I have the READ_PHONE_STATE, WRITE_SECURE_SETTINGS and the WRTE_SETTINGS permisson ticked when you generate the code.

Quite frustrating. Any suggestions?


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import android.net.Uri;
import java.io.File;
import android.graphics.Color;
import android.widget.TextView;
import android.widget.LinearLayout;
import android.view.ViewGroup.LayoutParams;
import android.graphics.Color;





public static void CallService() {

Context context = getContexteApplication();

BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Toast.makeText (context , "Received broadcast", Toast.LENGTH_LONG).show();
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if(state.equals(TelephonyManager.EXTRA_STATE_RINGING)){
Toast.makeText (context , "Ring ring", Toast.LENGTH_LONG).show();
}
}
};

Toast.makeText (context , "Start", Toast.LENGTH_LONG).show();



//2nd try
Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
//Intent intent = new Intent("android.intent.action.PHONE_STATE");
getActiviteEnCours().sendBroadcast(intent);
}

--
Erik