Ior*_*ori 8 clipboard service android
当任何用户从浏览器或短信等中复制任何内容时,我想制作一个简单的服务(将在后台运行),会有一个toast显示该文本
我有这个代码,当有电话时给予吐司
public class MyPhoneReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
// this code is for to accept the telephone call
String state = extras.getString(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
String phoneNumber = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Toast.makeText(context, phoneNumber, Toast.LENGTH_SHORT).show();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
和manifest.xml中的这段代码
<action android:name="android.intent.action.PHONE_STATE"></action>
Run Code Online (Sandbox Code Playgroud)
现在这段代码告诉myreciever我现在要向班级发送任何电话状态我想从剪贴板管理器获取文本.当有人复制文本时intent.action,是否有任何可以调用myreciever类的状态.
任何形式的帮助或代码将不胜感激.
| 归档时间: |
|
| 查看次数: |
7128 次 |
| 最近记录: |