I have this java code and I don't seem to be able to do the same in B4A in a straightforward way. I looked around in this forum but I get sparse bits of (sometimes contradictory) information, and not a single complete solution that I can tell. It's well possible that I'm still not very good at navigating forums, but I promise I will get better at it in due time
I need to:
Log both incoming and outgoing calls, then passing the incoming and outgoing numbers to an activity that can display the numbers or save them somewhere for later use.
Thank you in advance for any help you can provide.
Here's the java code I have:
IncomingCallReceiver.java
OutgoingCallReceiver.java
I need to:
Log both incoming and outgoing calls, then passing the incoming and outgoing numbers to an activity that can display the numbers or save them somewhere for later use.
Thank you in advance for any help you can provide.
Here's the java code I have:
IncomingCallReceiver.java
B4X:
package org.vruz.calllog.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
public class IncomingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if(null == bundle)
return;
Log.i("IncomingCallReceiver",bundle.toString());
String state = bundle.getString(TelephonyManager.EXTRA_STATE);
Log.i("IncomingCallReceiver","Call: "+ state);
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
{
String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Log.i("IncomingCallReceiver","Incoming number: " + phonenumber);
String info = "Incoming call from: " + phonenumber;
Toast.makeText(context, info, Toast.LENGTH_LONG).show();
}
}
}
OutgoingCallReceiver.java
B4X:
package org.vruz.calllog.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if(null == bundle)
return;
String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.i("OutgoingCallReceiver",phonenumber);
Log.i("OutgoingCallReceiver",bundle.toString());
String info = "Calling number: " + phonenumber;
Toast.makeText(context, info, Toast.LENGTH_LONG).show();
}
}