This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Android: Redirect outgoing calls
The requirement is to replace newly dialed number with another one. I have captured the ACTION_NEW_OUTGOING_CALL event and used Intent.EXTRA_PHONE_NUMBER to get the current outgoing number and then I have used setResultData inside my class(which extends BroadcastReceiver) to replace the dialed number. Basically code is,
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
String phonenbr =
intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.d("OutGoingNum", "phonenbr is " + phonenbr);
if (phonenbr.startsWith("00")) {
setResultData("12345678");
}
}
My code works fine in Android emulator but on the device the code works only on Redial. It doesnt work when you dial the number via dialpad. Please help.
I am guessing that Android won't allow the interception and replacement of a dialed number. It would be far too easy for someone to abuse this.
Related
This question already has answers here:
android-firebase childEventListener in service
(2 answers)
Android: Firebase realtime database updated when app destroyed
(1 answer)
Closed 10 months ago.
My Arduino-Uno(this chip is not related to this question) sends either one of two values to firebase, 1 or 0, I want it so that every time the value in the database is updated, it gets detected in android studio and it checks if the value updated is one
I don't particularly require a block of code, I just need to know the concept of this part. I want my app to check for the value even if the app is closed, for which which I did find something on stack overflow.
I want my app to check for the value even if the app is closed
That does not seem hard. You can use a Service class and then do the event listener task there. Since you haven't asked for any code, I won't share it.
This is a good post on it
This question already has answers here:
Programmatically obtain the phone number of the Android phone
(22 answers)
Closed 9 years ago.
I want to get mobile number of own mobile, for add this part to my application .
I'm searching about this question ,
code is correct on emulator but in device show empty.
public String getMyPhoneNumber()
{
return ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
.getLine1Number();
}
and :
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
But is it returning empty value. So How can I fetch the phone number detail ?
The method you are using is the only one part of the SDK to do this, and only works on devices where the number is stored on the SIM card, which only some carriers do. For all other carriers, you will have to ask the user to enter the phone number manually, as the number is simply not stored anywhere on the device from where you can retrieve it.
Answer from: Programmatically obtain the phone number of the Android phone
"There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (e.g. this is how porting is supported).
I know it is pain, but most likely the best solution is just to ask the user to enter his/her phone number once and store it."
Your code should be fine, but you need the SIM card to be inserted in the phone. Also, as autocrat noted, if the number is not stored on sim card, you will get an empty string.
EDIT: Also, please check the link provided by Pontus Backlund, there's some good info there.
Go to setting -> about device -> status -> my phone number if my phone number is unknown u won't get mobile number.. because some of the mobile network won't give mobile number..
if my mobile number has number u can get mobile through following code
TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
phoneNumber = tManager.getLine1Number();
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
how to dynamically get mobile IMEI number in J2me?
is there any way to get IMEI for J2ME supported all devices??i did some googling and find out the below solution but it is for device specific.
Nokia.
System.getProperty("com.nokia.IMEI");
SonyEricsson
System.getProperty("com.sonyericsson.imei");
Motorola
System.getProperty("com.motorola.IMEI");
is there any generic way to fetch IMEI for all devices??
There is no generic method to fetch IMEI for all devices, you have to do it by coding only. You can try it in alternate way like use System class as follows,
System.getProperty(“microedition.platform”);
This will going to return you the name of the host platform or device. In Nokia devices the name consists of “Nokia”, the device model, and software version separated by “/”. There is no space between “Nokia” and the model number nor on either side of “/”. Formally, the syntax of the platform string is: Nokia MODEL_NUMBER “/” SW_VERSION. For example, Nokia6310i/4.42 or Nokia3510i/p1.25.
From the result you can fetch the manufacture and use Switch case to get IMEI by coding,
i am developing an application that I need user phone number so I call the server from user's j2me application and I use platformRequest("tel:" + number); in my program for this purpose.
But the problem is that I don't know how I can abort the call because a minute ringing is sufficient for server to retrieving user number.
I want to know is there any API or instruction for canceling a call or some trick for it? for example is pushing the RED button programmatically possible in j2me?
No way to do this, best to get your server to terminate the call somehow.
This question already has an answer here:
Not getting correct value when retrieving current outgoing phone number in android
(1 answer)
Closed 9 years ago.
I am trying to get outgoing call number with intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER), but every time I try it returns null. I did put needed permissions and action in Androidmanifest. Can someone tell me what I am doing wrong or how to retrive number another way?
Ok, I found out what was wrong.
First of all intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER) gives you outgoing number while phone state is idle and turns to "null" while phone status changes to OFF_HOOK.
The easiest way was to save the number before another onRecive happens.