使用系统覆盖覆盖真正的呼叫者弹出窗口?

时间:2013-10-01 06:42:52

标签: java android

我实际上正在尝试开发一个可以覆盖Truecaller Popup的GUI。为此我想我必须创建一个系统覆盖与我想要显示的消息,使用窗口管理器,我也应该有一个接收器来监听意图Phone_State,但有些我的代码是如何工作的,P     这是代码段。

This is my receiver...

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.util.Log;
import android.view.Gravity;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class mReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {

        Log.d( "mReceiver" , "Inside mReceiver : First Line " );

        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams(LayoutParams.MATCH_PARENT,
                                    LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
                                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 
                                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | 
                                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, 
                                    PixelFormat.TRANSPARENT
                                    );

        params.height = LayoutParams.WRAP_CONTENT;
        params.width = LayoutParams.MATCH_PARENT;
        params.format = PixelFormat.TRANSLUCENT;

        params.gravity = Gravity.TOP;

        LinearLayout ly = new LinearLayout(context);
        ly.setBackgroundColor(Color.RED);
        ly.setOrientation(LinearLayout.VERTICAL);

        TextView tv = new TextView(context);

        tv.setText("Are We Above Truecaller !!! Cheers Yes We are!!!");

        ly.addView(tv);

        TextView tv2 = new TextView(context);

        tv2.setText("Are We Above Truecaller !!! Cheers Yes We are!!!");

        ly.addView(tv2);

        TextView tv3 = new TextView(context);

        tv3.setText("Are We Above Truecaller !!! Cheers Yes We are!!!");

        ly.addView(tv3);

        windowManager.addView(ly, params);

    }
}

This is my Manifest..

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.deathfinal"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <receiver android:name="com.example.deathfinal.mReceiver"
                  android:enabled="true">

            <intent-filter android:priority="199">

                <action android:name="android.intent.action.PHONE_STATE" />

                <category android:name="android.intent.category.HOME" />

            </intent-filter>
        </receiver>
    </application>

</manifest>

0 个答案:

没有答案