IP phone dial

Source: Internet
Author: User

The advantage of the IP phone dial is that when you need to add a prefix for each call, such as 17951, to reduce the cost of long-distance calls, you can automatically add it, instead of manually adding it each time, it mainly involves the following aspects:

1 first define a sharedpreferences to save the prefix to be added when you call

Package COM. DJF. ipnumber; import android. app. activity; import android. content. sharedpreferences; import android. content. sharedpreferences. editor; import android. OS. bundle; import android. view. menu; import android. view. menuitem; import android. view. view; import android. widget. edittext; import android. widget. toast; public class mainactivity extends activity {private edittext et_number; private sharedpreferences sp; @ override protected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_main); et_number = (edittext) findviewbyid (R. id. et_number); SP = getsharedpreferences ("ipnumber", mode_private);} public void save (view) {string ipnumber = et_number.gettext (). tostring (). trim (); Editor editor = sp. edit (); Editor. putstring ("ipnumber", ipnumber); Editor. commit (); toast. maketext (this, "saved successfully", 0 ). show ();}}

 

2. Define a broadcast receiver broadcastreceiver to listen to calls that will be called with a prefix before the call is made.

package com.djf.ipnumber;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;public class OutCallReceiver extends BroadcastReceiver {private SharedPreferences sp;@Overridepublic void onReceive(Context context, Intent intent) {// TODO Auto-generated method stubString number = getResultData();sp = context.getSharedPreferences("ipnumber",context.MODE_PRIVATE);String ipnumber = sp.getString("ipnumber", "");setResultData(ipnumber+number);}}

 

3. Note the permissions to be added.

<? XML version = "1.0" encoding = "UTF-8"?>
<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. DJF. ipnumber"
Android: versioncode = "1"
Android: versionname = "1.0" type = "codeph" text = "/codeph">

<Uses-SDK
Android: minsdkversion = "9"
Android: targetsdkversion = "17"/>
<Uses-Permission Android: Name = "android. Permission. process_outgoing_cils"/>


<Application
Android: allowbackup = "true"
Android: icon = "@ drawable/ic_launcher"
Android: Label = "@ string/app_name"
Android: theme = "@ style/apptheme">
<Activity
Android: Name = "com. DJF. ipnumber. mainactivity"
Android: Label = "@ string/app_name">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>

<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>

<Cycler Android: Name = "com. DJF. ipnumber. outcallreceiver">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. new_outgoing_call">
</Action>
</Intent-filter>
</Cycler>
</Application>

</Manifest>

IP phone dial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.