How to put automatically a phone number while calling - android

I'm trying to Make a little app which when I click on a button it makes a call and after few seconds (in the same default dialer activity) it displays automatically another number in the same default dialer activity.
I tried few ways but it didn't work !
there is my code for now :
Intent localIntent5 = new Intent(Intent.ACTION_CALL);
localIntent5.setData(Uri.parse("tel:0153204255"));
startActivity(localIntent5);
//wait a few seconds
localIntent5 = getIntent();
localIntent5.setData(Uri.parse("tel:71 0651755275%23"));
startActivity(localIntent5);
For now it just call the first number
Is it possible ? Thank you

you can use auto link for this purpose
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="phone"
android:text="#string/phoneValue"/>

Related

Android - Come back on my activity during a call

After have searched since more hour, I've found this about my problem (Stay on my activity when dialing)
but a negative answer.
My project consist to help a handicap (deaf people). I want to launch a call since my app and go back to my app (like return button) to show voice data.
Currently, I just need to do system like return button and I ask you in order to get help !
To call a number :
Intent dial = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "666-666-666"));
dial.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
startActivity(dial);
And I've a PhoneStateListener to know the state of the CALL.
The link I've shared's the only one I've found to this subject.
Thanks for reading.

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.

How to set an application to be default instead of making the user choose between several ones

I developed a dial up application and I installed it to my phone. Now I want to "on click a button" in my app to set the built in dialer as the default dialing application "automatically" without giving the user to choose between my app and the default dialer application.
This code gives the user the choice,
startActivityForResult(new Intent("android.intent.action.DIAL",
Uri.parse("tel:" + someNumber)), 1);
I don't want this, I want to set the default application to be built in dialer without asking the user.
Note: Once the user is not using my app he will be given the choice, Howevre, if he clicked that button in my app .. it will set the default app automatically.
Try this. This should open default dialer .
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:0000000000"));
startActivity(i);
You can't force the default activity without user interaction. Why don't you just call your class directly on the button press?
Intent intent = new Intent(this, mydialer.class))
intent.putExtra("PHONENUMBER", _phoneNumber);
startActivityForResult(intent);

Programmatically enter secret code like *#*#4636#*#* on Android

On many Android devices you can get into a secret settings menu from Phone app by typing in
*#*#4636#*#*
http://technology-headlines.com/2010/09/17/4636-android-secret-codes/
There are also some other codes.
Is it also possible to open this stuff programmatically?
I've tried this:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
But it just tries to initiate a phone call and of course fails, hangs up and closes the Phone app.
EDIT: The phone *#*#4636#*#* gets saved to my Contact list as "Unknown" but the call just fails. In fact, the secret code only works when you type manually on buttons in Phone app without pressing Call in the end. Is it probably just a hidden feature of Phone app which has nothing to do with calling?
If so, one could open the Phone app programmatically and simulate typing on the buttons.
According to this post
Programmatically press a button in another appplication's activity
this should NOT be possible because if any app on non-rooted phone could just start other apps and press something there, it could take over control of the whole device and do bad things.
Here are some more details but I guess the post is a bit old and even if it worked it may have been changed in current Android versions:
http://mylifewithandroid.blogspot.de/2009/01/generating-keypresses-programmatically.html
So, no easier way to enter secret code?
Is it also possible to open this stuff programmatically?
Yes:
Intent in = new Intent(Intent.ACTION_MAIN);
in.setClassName("com.android.settings", "com.android.settings.TestingSettings");
startActivity(in);
You just need to watch logcat output to learn what this magic combination actually opens:
I/ActivityManager(31362): START {act=android.intent.action.MAIN
flg=0x10000000 cmp=com.android.settings/.TestingSettings} from pid
4257
Secret codes exist and work independent of the dialer application. The dialer application just provides a handy interface for these codes. It recognizes the special string and then calls a special intent to invoke the action. You shouldn't use the dialer to call these dialogs. Instead you can call the secret codes directly yourself like the dialer does internally:
Invoking built in secret codes:
What the dialer really does when you enter the code is extracting the number between *#*# and #*#* and then broadcasting the following intent:
sendBroadcast(new Intent("android.provider.Telephony.SECRET_CODE", Uri.parse("android_secret_code://4636")));
Register your own secret codes (if you like):
You can even register your own secret code actions using:
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="4636" />
Source: http://android.amberfog.com/?p=422
Edit: Fixed a bug in the original code (see comment)
try this
String ussdCode = "*" +Uri.encode ("#")+"*"+Uri.encode ("#")+ "4636" + Uri.encode ("#")+"*"+Uri.encode ("#")+"*";
startActivity (new Intent ("android.intent.action.CALL", Uri.parse ("tel:" + ussdCode)));
finally you must encode '#' using Uri.encode()
ACTION_DIAL sends the user to the dialer with the given code (it does not call). So that would be :
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
It would appear that codes are to be dialed, rather than to be called
looking for this
Intent intent = new Intent("android.intent.action.MAIN");
intent.setClassName("com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
startActivity(intent);
There are different activities for different phone, we can jump to the activity through typing in ##4636##.
And use
adb shell dumsys activity activities
to find the realActivity package and name.
e.g: Xiaomi 8
Intent intent = new Intent("android.intent.action.MAIN");
intent.setClassName("com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
startActivity(intent);

How to go to web page after clicking on custom banner in app?

I have created a custom banner that is a simple rectangle picture that sits on the bottom of the first activity screen after the app is opened. It is being displayed as an ImageView with clickable="true". I have a setOnClickListener ready to go. Just need help with the code that actually takes the user to my website when they click on my custom banner. Also, need to know what permission to ask for to cover this. I would assume it is android.permission.INTERNET. Thanks for your help in advance.
Ok, here is the code that ended up working. Thanks guys.
Inside the xml layout file for this activity:
<ImageView
android:src="#drawable/saas_banner"
android:clickable="true"
android:id="#+id/SaasBannerIMG"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
Inside the onCreate method for the activity:
// add a click listener to the SaaS Ad Banner
ImageView img = (ImageView) findViewById(R.id.SaasBannerIMG);
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.websitetogoto.com"));
startActivity(intent);
}
});
Do you want it to open up the browser in order to view the webpage?
If you do, then you can try to do an implicit intent.
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.yourwebsite.com"));
startActivity(intent);
Put that in your button handler and the browser should load with the webpage.
You just need to set up an intent to start the browser with the required link. See this answer for the details: Sending an Intent to browser to open specific URL .
You do not need a specific permission, since the browsing will be handled by a different app (which does need the INTERNET permission).
This is, of course, unless you want to load the page yourself inside a WebView.

Categories

Resources