android开机调用搜狗输入法

最近感觉android系统自带的 输入法很不好用, 打字的时候老是点击错误, 于是把android系统自带的输入法从系统里直接干掉了(必须破解后),安装了搜狗输入法,感觉用搜狗的输入法输入文字非常快,中英文,标点符号切换都很快.但是如果手机每次重启的时候搜狗输入法启动的很慢,有时候就是启动不起来,所以无法输入文件信息.于是我就写下了下面的程序,开始自动启动搜狗输入法进程:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sunny.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
</application>
[i][b] <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>[/b][/i]
</manifest>

BootBroadcastReceiver.java:

package sunny.app;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootBroadcastReceiver extends BroadcastReceiver {
static final String ACTION = "android.intent.action.BOOT_COMPLETED";
int ActionFlag = 0;
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION)) {
Intent helloIntent = new Intent(context,StartSouGou.class);
helloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(helloIntent);
ActionFlag = -1;
}
}

}

StartSouGou.java:

package sunny.app;
import java.io.IOException;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class StartSouGou extends Service {
public IBinder onBind(Intent arg0) {
return null;
}
public int onStartCommand(Intent intent, int flags, int startId) {
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("com.sohu.inputmethod.sogou");
} catch (IOException e) {
}
return super.START_NOT_STICKY;
}
public void onDestroy() {
super.onDestroy();
}
}

com.sohu.inputmethod.sogou 为搜狗的进程
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值