New Out Going Call Action - android

In my application I have apply new outgoing call receiver. It is working fine. I get whenever new outgoing call is made.
But now, in my device there are two applications for dial call. First is default dialer and second is my own dialer (Using Call_Privilage).
My question is: when I got broadcast for new dial in my receiver at that time how can I know that from which dialer application call is dialed. From default dialer or my own dialer?

I have not implemented this and tested but I assume like this will work for you.
In your own dialer Activity whenever you are calling intent to make a call,
at that time you should pass one more putExtra with that callIntent
For Ex : callIntent.putExtra("fromMyDialer",1);
Now in your Receiver file, you will be having one method like this below and there you will just need to have check for the extra we passed above.
#Override
public void onReceive(final Context context, final Intent intent) {
if(intent.getIntExtra("fromMyDialer",0)==1)
// from my own dialer activity
else
// from default dialor of phone
}

Related

In Broadcast receiver class, onReceive method contains custom intent which is not working in Samsung mobile

Here i am trying to build a simple sms receiving app. In Broadcast receiver class,
I have the onReceive method which contains a custom intent which is not working in Samsung Mobile(4.1.2) but it works in kitkat 4.4(moto e).
Intent in = new Intent("SmsMessage.intent.MAIN").putExtra("get_body", sms_body);
context.sendBroadcast(in);
How do I do this in Android 4.1.2?
All you need to do if send some data via an intent right?
If no please do explain what you mean by broadcast not working.
If yes the put the following inside your onReceive() method.
Intent in = new Intent(context, ****Name of your activity****.class)
in.putExtra("get_body", sms_body)
context.startActivity(in);
Please do take note that where I have mentioned _****Name of your activity****_change it to the name of your activity
Inside your activity create a method onNewIntent ()
Inside which input the following code:
String textInSms = intent.getStringExtra("get_body")
That's it now you can do whatever you want with the textInSms string. It holds the value of whatever extra you passed to it.

Android - Hide calling phone number when call is made through my app?

I have button in my Android app to call a desired phone number.
I want to hide this number from callers call log (Yes, I want to hide it from displaying androids call log) is there any possible way for me to display calls made by my app as strings (Eg. if you call 12345678; i want to display it as "my numb")
This is my current code to make the call
public void callUsNow(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:1234567890"));
con.startActivity(callIntent);
}
Could anyone suggest on this?
Thanks.
No.
If you pass Intent by calling Intent.ACTION_CALL, after con.startActivity(callIntent) other activity will have control over it.

Activity closes in blink after end call

I am calling a activity from my service when an incoming call ends as given below
Intent callIntent1 = new Intent(Intent.ACTION_CALL);
callIntent1.addCategory(Intent.CATEGORY_HOME);
callIntent1.addCategory(Intent.CATEGORY_LAUNCHER);
callIntent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callIntent1.setClass(context, com.example.test.MyActivity.class);
Log.d("TAG", "MyActivity");
startActivity(callIntent1);
but my activity starts for a blink and closes and I see the home screen ,my log shows the call given to MyActivity ,I cannot find the reason for this
I think it is because you are not using your intent categories the right way. If you are explicitly calling the startActivity method, you don't need to add a category to your intent. They are meant to be used with intent filters I guess. If you want to detect something, eg a call, a text etc, add an intent filter to your activity.
Edit: see here

Android StartAcitivty() with intent

I'm making a SIP application, and I've got pretty much everything working that i want to except one thing. I cant get the activity to launch when a SIP call occurs.
I'm working with a SIP library that starts a 'phone' service which deals with the handling of incoming calls etc, and when i create an instance of the 'phone' I then register listeners which detail what i want to happen. So to handle incoming calls i register an 'OnIncommingCall' listener.
If the app isn't currently open at the time i want it to launch the app. so my listener is:
thisPhone.setIncomingCallListener(new OnIncomingCallListener()
{
public void OnIncomingCall(String remoteContact, int accountId)
{
if(MainActivity.this.getIsOpen())
{
MainActivity.this.setIsCallIncomming(true);
MainActivity.this.setCurrentCaller(remoteContact);
MainActivity.this.setMainUIEles();
}
else
{
Intent i = new Intent(getApplicationContext(), MainActivity.class);
i.putExtra("isCallIncomming", true);
i.putExtra("currentCaller", remoteContact);
i.putExtra("isRegistered", true);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
}
}); //incoming call listener
However when the call comes, it rings but the app wont open, but if i open the app from the launcher whilst the call is still ringing then it will open and know the call is there.
Is the problem because I'm trying to start the Activity which defined the listener?
I've tried all sorts of flags and combinations (SINGLE_TOP etc) can i can't get it to work.
Any help would be appreciated!
DJOodlen
Well this was a silly mistake on my part.
After putting in some toasts so I could see where in the code each bit was going I realised that getIsOpen() never returned false. That's because it wasn't being called on the onPause() method as wells as the onDestroy() method...
Ooops!

How to resume an action when quitting with home button?

I'm developping a SIP application. I have a little problem: when "reducing" the application with home button and i make a call to the phone, i have the coded ringing incoming call but the application doesn't shows. How to pops up all the application UI when having an incoming call ?
Thank you for your help.
EDIT:
public class IncomingCallReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Dialog dialog = new Dialog(context,intent);
dialog.répondre();
}
}
So, you have an Activity that is stopped and you want to pop it up when call arrives. Approach I would suggest:
originally start that Activity with flag FLAG_ACTIVITY_SINGLE_TOP
override function onNewIntent() in that Activity and process incoming Intent depending on action code from Intent (you define them to distinguish reasons for popping up)
when you want to move that Activity to foreground again, call startActivity() with some action code (you can to that from Service as well). If Activity is not started, it will be. If it is started, it will not be re-started but resumed and you will receive your Intent in onNewIntent() and your Activity will be moved to foreground.
UPDATE:
onNewIntent() handling example:
\android-sdk-windows\samples\android-8\ApiDemos\src\com\example\android\apis\app\SearchQueryResults.java

Categories

Resources