来去电悬浮窗提示号码,联系人,联系人头像

来源:互联网 发布:网络阅读的利与弊300 编辑:程序博客网 时间:2024/05/18 15:28

本篇内容是本人整理,测试,调整,网上的相关代码之后得到的。如果侵犯您的相关权益,请通知本人,本人会立即申明或者删除,谢谢!

1.添加来去电广播接收。

建立继承BroadcastReceiver的类PhoneCall(类名随意)。

public class PhoneCall extends BroadcastReceiver {


//private static boolean mIncomingFlag = false;
private static String mIncomingNumber = null;


@Override
public void onReceive(Context context, Intent intent) {
// 如果是拨打电话
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
//mIncomingFlag = false;
String phoneNumber = intent
.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Intent mintent = new Intent(context, PhoneService.class);
mintent.putExtra("phoneNum", phoneNumber);
context.startService(mintent);
} else {
// 如果是来电
TelephonyManager tManager = (TelephonyManager) context
.getSystemService(Service.TELEPHONY_SERVICE);
switch (tManager.getCallState()) {
case TelephonyManager.CALL_STATE_RINGING:
//mIncomingFlag = true;
mIncomingNumber = intent.getStringExtra("incoming_number");
Intent mintent = new Intent(context, PhoneService.class);
mintent.putExtra("phoneNum", mIncomingNumber);
context.startService(mintent);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
case TelephonyManager.CALL_STATE_IDLE:
//if (mIncomingFlag) {
Intent endintent = new Intent(context, PhoneService.class);
context.stopService(endintent);
//}
break;
}
}
}
}

接着在AndroidManifest.xml    文件中注册

<receiver android:name=".PhoneCall">  
            <intent-filter>  
                <action android:name="android.intent.action.PHONE_STATE" />  
                 <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
            </intent-filter>  

 </receiver>

再添加相关权限

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>

2.在上面的代码中我们启动了一个服务service,并且启动时将去电号码或者来电号码传递给了service

添加类PhoneService(类名随意)继承自Service

public class PhoneService extends Service {
// 定义浮动窗口布局
LinearLayout mFloatLayout;
WindowManager.LayoutParams wmParams;
// 创建浮动窗口设置布局参数的对象
WindowManager mWindowManager;
// 悬浮窗按钮,显示名称
Button mFloatView;
// 悬浮窗按钮,显示号码
Button mFloatNum;
// 悬浮窗按钮,显示信息
Button mFloatInfo;
// 悬浮窗按钮,接通电话
Button GetPhone;
// 悬浮窗按钮,拒接电话
Button EndPhone;
// 悬浮窗按钮,显示图像
ImageView mFloatIm;
// 悬浮窗显示的电话号码信息
String infonum = "";
// 悬浮窗显示的名称信息
String infoname = "";
// 悬浮窗显示的提示信息
String infotip="";

//获取到所有联系人信息,根据号码得到姓名  其中ContactInfo 为自定类

private List<ContactInfo> infos = new ArrayList<ContactInfo>();
private static final String TAG = "FxService";

/*
* (non-Javadoc) //只在服务第一次启动的时候调用,并且在onStartCommand前面 所以 不能在这里创建窗口,不然收不到信息
*/
@Override
public void onCreate() {
super.onCreate();
// Log.i(TAG, "oncreat");
// createFloatView();
}


@Override
public int onStartCommand(Intent intent, int flags, int startId) {
infonum = intent.getStringExtra("phoneNum");// 得到来电号码
infos = ApplicationSS.getInstance().getInfos();//在Application类中定义,其内容后面给出
for (int i = 0; i < infos.size(); i++) {
if (infos.get(i).getPhone().equals(infonum)) {
infoname = infos.get(i).getName();
break;
}
}

if (infoname == "") {
infoname = "陌生号码";
}
createFloatView();//创建窗口
return super.onStartCommand(intent, flags, startId);
}


@Override
public IBinder onBind(Intent intent) {
return null;
}


private boolean IsRoaming() {
// 如果手机处于漫游状态,则显示提示信息,否则隐藏提示
ServiceState serviceState = new ServiceState();
boolean roaming = serviceState.getRoaming();
return roaming;
}


private void createFloatView() {
wmParams = new WindowManager.LayoutParams();
// 获取WindowManagerImpl.CompatModeWrapper
mWindowManager = (WindowManager) getApplication().getSystemService(
getApplication().WINDOW_SERVICE);
// 设置window type
wmParams.type = LayoutParams.TYPE_PHONE; // 不在状态栏之上
// 设置窗口类型在所有窗口之上,包括状态栏,设置为此属性,则不能获得焦点,点击事件
// wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
// 设置图片格式,效果为背景透明
wmParams.format = PixelFormat.RGBA_8888;
// 设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作)
wmParams.flags =
// LayoutParams.FLAG_NOT_TOUCH_MODAL |
LayoutParams.FLAG_NOT_FOCUSABLE
// LayoutParams.FLAG_NOT_TOUCHABLE
;


// 调整悬浮窗显示的停靠位置为左侧置顶
wmParams.gravity = Gravity.START | Gravity.TOP;


// 以屏幕左上角为原点,设置x、y初始值
wmParams.x = 0;
wmParams.y = 0;


/*
* // 设置悬浮窗口长宽数据 wmParams.width = 200; wmParams.height = 80;
*/


// 设置悬浮窗口长宽数据
wmParams.width = WindowManager.LayoutParams.MATCH_PARENT;
wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;


LayoutInflater inflater = LayoutInflater.from(getApplication());
// 获取浮动窗口视图所在布局
mFloatLayout = (LinearLayout) inflater.inflate(R.layout.float_layout,
null);
// 设置颜色
mFloatLayout.setBackgroundColor(getResources().getColor(
R.color.peachpuff));
// 添加mFloatLayout
mWindowManager.addView(mFloatLayout, wmParams);


/*
* Log.i(TAG, "mFloatLayout-->left" + mFloatLayout.getLeft());
* Log.i(TAG, "mFloatLayout-->right" + mFloatLayout.getRight());
* Log.i(TAG, "mFloatLayout-->top" + mFloatLayout.getTop()); Log.i(TAG,
* "mFloatLayout-->bottom" + mFloatLayout.getBottom());
*/


// 浮动窗口按钮
mFloatView = (Button) mFloatLayout.findViewById(R.id.float_id);
mFloatView.setBackground(getResources().getDrawable(R.drawable.shape));// 设置shape样式
mFloatView.setTextSize(35);// 设置字体信息
mFloatView.setTextColor(Color.BLACK);
mFloatView.setText(infonum);// 设置信息
mFloatNum = (Button) mFloatLayout.findViewById(R.id.float_num);
mFloatNum.setBackground(getResources().getDrawable(R.drawable.shape));// 设置shape样式
mFloatNum.setTextSize(35);// 设置字体信息
mFloatNum.setTextColor(Color.BLACK);
mFloatNum.setText(infoname);// 设置信息
GetPhone = (Button) mFloatLayout.findViewById(R.id.float_getphone);
GetPhone.setBackground(getResources().getDrawable(R.drawable.selector));// 设置shape样式
GetPhone.setTextSize(35);// 设置字体信息
Point size = new Point();
mWindowManager.getDefaultDisplay().getSize(size);// 得到屏幕大小
GetPhone.setWidth(size.x / 2);
GetPhone.setTextColor(Color.BLACK);
EndPhone = (Button) mFloatLayout.findViewById(R.id.float_endphone);
EndPhone.setBackground(getResources().getDrawable(R.drawable.selector));// 设置shape样式
EndPhone.setTextSize(35);// 设置字体信息
EndPhone.setWidth(size.x / 2);
EndPhone.setTextColor(Color.BLACK);
if (IsRoaming()) {
mFloatInfo = (Button) mFloatLayout.findViewById(R.id.float_info);
mFloatInfo.setVisibility(View.VISIBLE);
mFloatInfo.setBackground(getResources().getDrawable(
R.drawable.shape));// 设置shape样式
mFloatInfo.setTextSize(35);// 设置字体信息
mFloatInfo.setTextColor(Color.BLACK);
mFloatInfo.setText(infotip);// 设置信息
}


// View.MeasureSpec.makeMeasureSpec(int size,int mode)根据提供的大小值和模式创建一个测量值
/*
* 模式 UNSPECIFIED 无限制 parent view不约束child AT_MOST 最多的 wrap_content child
* view可以在parent view范围内取值 EXACTLY 准确的 fill_parent(例如50dip) parent
* view为child view指定固定大小
*/
mFloatLayout.measure(View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED), View.MeasureSpec
.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
// Log.i(TAG, "Width/2--->" + mFloatView.getMeasuredWidth() / 2);
// Log.i(TAG, "Height/2--->" + mFloatView.getMeasuredHeight() / 2);
// 设置监听浮动窗口的触摸移动
// 设置监听浮动窗口的触摸移动   代码被注释,取消注释即可运行
/*
* mFloatView.setOnTouchListener(new OnTouchListener() {

* @Override public boolean onTouch(View v, MotionEvent event) { // TODO
* Auto-generated method stub //getRawX是触摸位置相对于屏幕的坐标,getX是相对于按钮的坐标
* wmParams.x = (int) event.getRawX() - mFloatView.getMeasuredWidth()/2;
* //Log.i(TAG, "Width/2--->" + mFloatView.getMeasuredWidth()/2);
* Log.i(TAG, "RawX" + event.getRawX()); Log.i(TAG, "X" + event.getX());
* //25为状态栏的高度 wmParams.y = (int) event.getRawY() -
* mFloatView.getMeasuredHeight()/2 - 25; // Log.i(TAG, "Width/2--->" +
* mFloatView.getMeasuredHeight()/2); Log.i(TAG, "RawY" +
* event.getRawY()); Log.i(TAG, "Y" + event.getY()); //刷新
* mWindowManager.updateViewLayout(mFloatLayout, wmParams); return
* false; } });
*/
/*
* mFloatView.setOnClickListener(new OnClickListener() {

* @Override public void onClick(View v) {
* Toast.makeText(PhoneService.this, "onClick",
* Toast.LENGTH_SHORT).show(); //endCall(getApplicationContext()); } });
*/
EndPhone.setOnTouchListener(new OnTouchListener() {
// 挂断
@Override
public boolean onTouch(View v, MotionEvent event) {
// mActLayout.setVisibility(View.INVISIBLE);//隐藏显示,但是占据布局
switch (event.getAction()) {


case MotionEvent.ACTION_DOWN: {
// 按下时触发
}


case MotionEvent.ACTION_MOVE: {
// 移动时触发
}


case MotionEvent.ACTION_UP: {
// 触摸后触发
EndPhone.setVisibility(View.INVISIBLE);
GetPhone.setVisibility(View.INVISIBLE);
endCall(getApplicationContext());
// stopSelf();
// 防止接收不到广播,点击挂断后结束service
Intent intent = new Intent(getApplicationContext(),
PhoneService.class);
// getApplication().stopService(intent);
getApplication().stopService(intent);
// GetPhone.performClick();//模拟点击按钮
}
}
return false;
}
});
/*
* GetPhone.setOnClickListener(new OnClickListener() {

* @Override public void onClick(View v) {
* endCall(getApplicationContext()); } });
*/
}


/**
* 挂断电话
*/
public static synchronized void endCall(Context ctx) {
TelephonyManager mTelMgr = (TelephonyManager) ctx
.getSystemService(Service.TELEPHONY_SERVICE);
Class<TelephonyManager> c = TelephonyManager.class;
try {
Method getITelephonyMethod = c.getDeclaredMethod("getITelephony",
(Class[]) null);
getITelephonyMethod.setAccessible(true);
ITelephony iTelephony = null;
// System.out.println("End call.");
iTelephony = (ITelephony) getITelephonyMethod.invoke(mTelMgr,
(Object[]) null);
iTelephony.endCall();
} catch (Exception e) {
e.printStackTrace();
// System.out.println("Fail to answer ring call.");
}
}


@Override
public void onDestroy() {
if (mFloatLayout != null) {
mWindowManager.removeView(mFloatLayout);
}
super.onDestroy();
}

}

其中用到的类

ContactInfo   通讯录联系人信息

public class ContactInfo {
private String name;
private String phone;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}

ApplicationSS  继承自Application   ,需要在AndroidManifest.xml文件的application节点中添加android:name="包名.ApplicationSS",其中包名用自己工程的

public class  ApplicationSS extends Application {
/** 手机联系人 必须new出来 */
private List<ContactInfo> infos;
public List<ContactInfo> getInfos() {
return infos;
}
private static ApplicationSS mInstance;


public static ApplicationSS getInstance() {
return mInstance;
}
//使用工具类
private HelpTool mHelpTool;
@Override
public void onCreate() {
infos = new ArrayList<ContactInfo>();
mHelpTool = new HelpTool();
infos = mHelpTool.readContacts(this);
mInstance=this;
super.onCreate();
}
}

上面又用到工具类  HelpTool

新建类HelpTool,然后实现成员函数

/**
* 获取所有联系人内容

* @param context
* @param address
* @return
*/

public List<ContactInfo> readContacts(Context context) {
List<ContactInfo> infos = new ArrayList<ContactInfo>();
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null, null, null, null);
while (cursor.moveToNext()) {
ContactInfo contactInfo = new ContactInfo();
String displayName = cursor.getString(cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String number = cursor.getString(cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
contactInfo.setName(displayName);
contactInfo.setPhone(number);
infos.add(contactInfo);
contactInfo = null;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
return infos;
}


其中用到的xml配置文件

res/layout目录下   float_layout.xml文件主要配置悬浮窗UI界面, 其中使用到的图片请自行添加并更改图片文件名

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >


    <Button
        android:id="@+id/float_id"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="你好" />


    <Button
        android:id="@+id/float_num"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="你好" />


    <Button
        android:id="@+id/float_info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="你好"
        android:visibility="gone" />


    <ImageView
        android:id="@+id/float_im"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ali" />


    <LinearLayout
        android:id="@+id/float_actphone"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >


        <Button
            android:id="@+id/float_endphone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="拒接" />
        <Button
            android:id="@+id/float_getphone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="接听" />
    </LinearLayout>
</LinearLayout>

按钮样式和各种状态的效果  按下、获取焦点等

res/drawable/目录下

selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/shapepress" android:state_pressed="true"/>  
    <item android:drawable="@drawable/shape" android:state_focused="false" android:state_pressed="false"/>  
    <item android:drawable="@drawable/shape"  android:state_focused="true"/>  
    <item android:drawable="@drawable/shape" android:state_focused="false"/>  
</selector>

shape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 定义渐变色 (从左下角到右上角绘制渐变色) -->
<gradient android:startColor="@color/lightgreen" android:endColor="@color/greenyellow"
android:angle="45" />
<!-- 定义控件内容到边界的距离 (到四条边界的距离都是7) -->
<padding android:left="7dp" android:top="7dp" android:right="7dp"
android:bottom="7dp" />
<!-- 定义边框线 (边框线宽度是2) -->
<stroke android:width="2dp" android:color="@color/lightskyblue" />
<!-- 定义圆角 (圆角半径是8) -->
<corners android:radius="8dp" />
</shape>
<!-- 在xml里面    android:background="@drawable/shape" -->
<!-- 可以使用代码加载shape -->
<!-- Resource res=getresources() -->
<!-- Drawable shape = res.getDrawable(R.drawable.shape) -->
<!-- TextView tv = (TextView) findViewByID(R.id.text)-->
<!-- tv.setBackground(shape)-->

shapepress.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 定义渐变色 (从左下角到右上角绘制渐变色) -->
<gradient android:startColor="@color/azure" android:endColor="@color/lightblue"
android:angle="45" />
<!-- 定义控件内容到边界的距离 (到四条边界的距离都是7) -->
<padding android:left="7dp" android:top="7dp" android:right="7dp"
android:bottom="7dp" />
<!-- 定义边框线 (边框线宽度是2) -->
<stroke android:width="2dp" android:color="@color/lightskyblue" />
<!-- 定义圆角 (圆角半径是8) -->
<corners android:radius="8dp" />
</shape>
<!-- 在xml里面    android:background="@drawable/shape" -->
<!-- 可以使用代码加载shape -->
<!-- Resource res=getresources() -->
<!-- Drawable shape = res.getDrawable(R.drawable.shape) -->
<!-- TextView tv = (TextView) findViewByID(R.id.text)-->
<!-- tv.setBackground(shape)-->


其中用到了color.xml,来自网上

res/value/color.xml

<?xml version="1.0" encoding="utf-8"?>


<resources>


<color name="white">#FFFFFF</color><!--白色 -->


<color name="ivory">#FFFFF0</color><!--象牙色 -->


<color name="lightyellow">#FFFFE0</color><!--亮黄色 -->


<color name="yellow">#FFFF00</color><!--黄色 -->


<color name="snow">#FFFAFA</color><!--雪白色 -->


<color name="floralwhite">#FFFAF0</color><!--花白色 -->


<color name="lemonchiffon">#FFFACD</color><!--柠檬绸色 -->


<color name="cornsilk">#FFF8DC</color><!--米绸色 -->


<color name="seashell">#FFF5EE</color><!--海贝色 -->


<color name="lavenderblush">#FFF0F5</color><!--淡紫红 -->


<color name="papayawhip">#FFEFD5</color><!--番木色 -->


<color name="blanchedalmond">#FFEBCD</color><!--白杏色 -->


<color name="mistyrose">#FFE4E1</color><!--浅玫瑰色 -->


<color name="bisque">#FFE4C4</color><!--桔黄色 -->


<color name="moccasin">#FFE4B5</color><!--鹿皮色 -->


<color name="navajowhite">#FFDEAD</color><!--纳瓦白 -->


<color name="peachpuff">#FFDAB9</color><!--桃色 -->


<color name="gold">#FFD700</color><!--金色 -->


<color name="pink">#FFC0CB</color><!--粉红色 -->


<color name="lightpink">#FFB6C1</color><!--亮粉红色 -->


<color name="orange">#FFA500</color><!--橙色 -->


<color name="lightsalmon">#FFA07A</color><!--亮肉色 -->


<color name="darkorange">#FF8C00</color><!--暗桔黄色 -->


<color name="coral">#FF7F50</color><!--珊瑚色 -->


<color name="hotpink">#FF69B4</color><!--热粉红色 -->


<color name="tomato">#FF6347</color><!--西红柿色 -->


<color name="orangered">#FF4500</color><!--红橙色 -->


<color name="deeppink">#FF1493</color><!--深粉红色 -->


<color name="fuchsia">#FF00FF</color><!--紫红色 -->


<color name="magenta">#FF00FF</color><!--红紫色 -->


<color name="red">#FF0000</color><!--红色 -->


<color name="oldlace">#FDF5E6</color><!--老花色 -->


<color name="lightgoldenrodyellow">#FAFAD2</color><!--亮金黄色 -->


<color name="linen">#FAF0E6</color><!--亚麻色 -->


<color name="antiquewhite">#FAEBD7</color><!--古董白 -->


<color name="salmon">#FA8072</color><!--鲜肉色 -->


<color name="ghostwhite">#F8F8FF</color><!--幽灵白 -->


<color name="mintcream">#F5FFFA</color><!--薄荷色 -->


<color name="whitesmoke">#F5F5F5</color><!--烟白色 -->


<color name="beige">#F5F5DC</color><!--米色 -->


<color name="wheat">#F5DEB3</color><!--浅黄色 -->


<color name="sandybrown">#F4A460</color><!--沙褐色 -->


<color name="azure">#F0FFFF</color><!--天蓝色 -->


<color name="honeydew">#F0FFF0</color><!--蜜色 -->


<color name="aliceblue">#F0F8FF</color><!--艾利斯兰 -->


<color name="khaki">#F0E68C</color><!--黄褐色 -->


<color name="lightcoral">#F08080</color><!--亮珊瑚色 -->


<color name="palegoldenrod">#EEE8AA</color><!--苍麒麟色 -->


<color name="violet">#EE82EE</color><!--紫罗兰色 -->


<color name="darksalmon">#E9967A</color><!--暗肉色 -->


<color name="lavender">#E6E6FA</color><!--淡紫色 -->


<color name="lightcyan">#E0FFFF</color><!--亮青色 -->


<color name="burlywood">#DEB887</color><!--实木色 -->


<color name="plum">#DDA0DD</color><!--洋李色 -->


<color name="gainsboro">#DCDCDC</color><!--淡灰色 -->


<color name="crimson">#DC143C</color><!--暗深红色 -->


<color name="palevioletred">#DB7093</color><!--苍紫罗兰色-->


<color name="goldenrod">#DAA520</color><!--金麒麟色 -->


<color name="orchid">#DA70D6</color><!--淡紫色 -->


<color name="thistle">#D8BFD8</color><!--蓟色 -->


<color name="lightgray">#D3D3D3</color><!--亮灰色 -->


<color name="lightgrey">#D3D3D3</color><!--亮灰色 -->


<color name="tan">#D2B48C</color><!--茶色 -->


<color name="chocolate">#D2691E</color><!--巧可力色 -->


<color name="peru">#CD853F</color><!--秘鲁色 -->


<color name="indianred">#CD5C5C</color><!--印第安红 -->


<color name="mediumvioletred">#C71585</color><!--中紫罗兰色 -->


<color name="silver">#C0C0C0</color><!--银色 -->


<color name="darkkhaki">#BDB76B</color><!--暗黄褐色 -->


<color name="rosybrown">#BC8F8F</color><!--褐玫瑰红 -->


<color name="mediumorchid">#BA55D3</color><!--中粉紫色 -->


<color name="darkgoldenrod">#B8860B</color><!--暗金黄色 -->


<color name="firebrick">#B22222</color><!--火砖色 -->


<color name="powderblue">#B0E0E6</color><!--粉蓝色 -->


<color name="lightsteelblue">#B0C4DE</color><!--亮钢兰色-->


<color name="paleturquoise">#AFEEEE</color><!--苍宝石绿 -->


<color name="greenyellow">#ADFF2F</color><!--黄绿色 -->


<color name="lightblue">#ADD8E6</color><!--亮蓝色 -->


<color name="darkgray">#A9A9A9</color><!--暗灰色 -->


<color name="darkgrey">#A9A9A9</color><!--暗灰色 -->


<color name="brown">#A52A2A</color><!--褐色 -->


<color name="sienna">#A0522D</color><!--赭色 -->


<color name="darkorchid">#9932CC</color><!--暗紫色 -->


<color name="palegreen">#98FB98</color><!--苍绿色 -->


<color name="darkviolet">#9400D3</color><!--暗紫罗兰色 -->


<color name="mediumpurple">#9370DB</color><!--中紫色 -->


<color name="lightgreen">#90EE90</color><!--亮绿色 -->


<color name="darkseagreen">#8FBC8F</color><!--暗海兰色 -->


<color name="saddlebrown">#8B4513</color><!--重褐色 -->


<color name="darkmagenta">#8B008B</color><!--暗洋红 -->


<color name="darkred">#8B0000</color><!--暗红色 -->


<color name="blueviolet">#8A2BE2</color><!--紫罗兰蓝色 -->


<color name="lightskyblue">#87CEFA</color><!--亮天蓝色 -->


<color name="skyblue">#87CEEB</color><!--天蓝色 -->


<color name="gray">#808080</color><!--灰色 -->


<color name="grey">#808080</color><!--灰色 -->


<color name="olive">#808000</color><!--橄榄色 -->


<color name="purple">#800080</color><!--紫色 -->


<color name="maroon">#800000</color><!--粟色 -->


<color name="aquamarine">#7FFFD4</color><!--碧绿色 -->


<color name="chartreuse">#7FFF00</color><!--黄绿色 -->


<color name="lawngreen">#7CFC00</color><!--草绿色 -->


<color name="mediumslateblue">#7B68EE</color><!--中暗蓝色-->


<color name="lightslategray">#778899</color><!--亮蓝灰 -->


<color name="slategray">#708090</color><!--灰石色 -->


<color name="olivedrab">#6B8E23</color><!--深绿褐色 -->


<color name="slateblue">#6A5ACD</color><!--石蓝色 -->


<color name="dimgray">#696969</color><!--暗灰色 -->


<color name="mediumaquamarine">#66CDAA</color><!--中绿色-->


<color name="cornflowerblue">#6495ED</color><!--菊兰色 -->


<color name="cadetblue">#5F9EA0</color><!--军兰色 -->


<color name="darkolivegreen">#556B2F</color><!--暗橄榄绿 -->


<color name="indigo">#4B0082</color><!--靛青色 -->


<color name="mediumturquoise">#48D1CC</color><!--中绿宝石-->


<color name="darkslateblue">#483D8B</color><!--暗灰蓝色 -->


<color name="steelblue">#4682B4</color><!--钢兰色 -->


<color name="royalblue">#4169E1</color><!--皇家蓝 -->


<color name="turquoise">#40E0D0</color><!--青绿色 -->


<color name="mediumseagreen">#3CB371</color><!--中海蓝 -->


<color name="limegreen">#32CD32</color><!--橙绿色 -->


<color name="darkslategray">#2F4F4F</color><!--暗瓦灰色 -->


<color name="darkslategrey">#2F4F4F</color><!--暗瓦灰色 -->


<color name="seagreen">#2E8B57</color><!--海绿色 -->


<color name="forestgreen">#228B22</color><!--森林绿 -->


<color name="lightseagreen">#20B2AA</color><!--亮海蓝色 -->


<color name="dodgerblue">#1E90FF</color><!--闪兰色 -->


<color name="midnightblue">#191970</color><!--中灰兰色 -->


<color name="aqua">#00FFFF</color><!--浅绿色 -->


<color name="cyan">#00FFFF</color><!--青色 -->


<color name="springgreen">#00FF7F</color><!--春绿色 -->


<color name="lime">#00FF00</color><!--酸橙色 -->


<color name="mediumspringgreen">#00FA9A</color><!--中春绿色 -->


<color name="darkturquoise">#00CED1</color><!--暗宝石绿 -->


<color name="deepskyblue">#00BFFF</color><!--深天蓝色 -->


<color name="darkcyan">#008B8B</color><!--暗青色 -->


<color name="teal">#008080</color><!--水鸭色 -->


<color name="green">#008000</color><!--绿色 -->


<color name="darkgreen">#006400</color><!--暗绿色 -->


<color name="blue">#0000FF</color><!--蓝色 -->


<color name="mediumblue">#0000CD</color><!--中兰色 -->


<color name="darkblue">#00008B</color><!--暗蓝色 -->


<color name="navy">#000080</color><!--海军色 -->


<color name="black">#000000</color><!--黑色 -->


</resources>


关于挂断电话,采用了反射机制。接通电话4.4以上尚未找到好代码,本人目前在反编译其他相关软件,如果成果会更新

src目录下  

com.android.internal.telephony

 其中有ITelephony.aidl  ,这里面内容很简单

package com.android.internal.telephony;


interface ITelephony {
    boolean endCall();


    //void answerRingingCall();
}

本人会上传相关文件,只需要添加到工程的src目录下即可

http://download.csdn.net/detail/silenceshining/8657819

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 顶替姐姐上班已到退休年龄怎么办 年龄过60岁厂里拖欠工资怎么办 领导找人顶替我怎么办 宁夏超生了没钱交罚款怎么办? 户口年龄上大了怎么办 孩子年龄报小了怎么办 招工档案年龄有涂改怎么办 退伍军被别人顶替上班怎么办 二孩政策前生的怎么办 孩子晕车怎么办最有效方法得当 事业单位编外人员改革工伤怎么办 工伤仲裁后法院一审判决后怎么办 我媳妇删了我该怎么办 老婆离家出走不照顾小孩怎么办 车停在4s店损坏怎么办 车辆年检贴丢了怎么办 卖衣服别人嫌贵怎么办 武汉铁路医保卡丢了怎么办 高铁列车员年龄大了怎么办 尚客优酒店会员怎么办 钢铁雄心4人力不足怎么办 未经车主同意私自将车卖了怎么办 剧本给几个制片人看过怎么办 没有产品经理ui设计师怎么办 老板请朋友吃饭司机应该怎么办 被化妆学校坑了怎么办 快车约得太远怎么办 工资好低2000多怎么办 苹果手机不能下载软件怎么办 苹果手机下不了软件怎么办 苹果6s下不了软件怎么办 苹果6下不了软件怎么办 ipad更新系统卡住了怎么办 ipad卡住了关不了机怎么办 ipad卡住了没反应怎么办 苹果7下不了软件怎么办 苹果手机开机密码忘了怎么办 苹果开机密码忘了怎么办 我的ipad很卡怎么办 6s升级后卡顿严重怎么办 软件升级后手机卡顿怎么办