本文整理汇总了Java中android.content.ClipboardManager.OnPrimaryClipChangedListener方法的典型用法代码示例。如果您正苦于以下问题:Java ClipboardManager.OnPrimaryClipChangedListener方法的具体用法?Java ClipboardManager.OnPrimaryClipChangedListener怎么用?Java ClipboardManager.OnPrimaryClipChangedListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ClipboardManager
的用法示例。
在下文中一共展示了ClipboardManager.OnPrimaryClipChangedListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.content.ClipboardManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
context=getApplicationContext();
mClipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
createNotificationChannel();
listener = new ClipboardManager.OnPrimaryClipChangedListener() {
public void onPrimaryClipChanged() {
performClipboardCheck();
}
};
}
示例2: readyClipboard
import android.content.ClipboardManager; //导入方法依赖的package包/类
private void readyClipboard(ClipboardManager.OnPrimaryClipChangedListener listener) {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
if (null != mPrimaryClipChangedListener) {
clipboardManager.removePrimaryClipChangedListener(mPrimaryClipChangedListener);
}
mPrimaryClipChangedListener = listener;
clipboardManager.addPrimaryClipChangedListener(mPrimaryClipChangedListener);
}
示例3: onStartCommand
import android.content.ClipboardManager; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//super.onStartCommand(intent, flags, startId);
if((intent!=null)&&(intent.hasExtra(INSTASHARE_MESSAGE))){
switch (intent.getIntExtra(INSTASHARE_MESSAGE,DO_NONE)) {
case START:
if (mOnPrimaryClipChangedListener == null){
mOnPrimaryClipChangedListener =
new ClipboardManager.OnPrimaryClipChangedListener() {
@Override
public void onPrimaryClipChanged() {
Log.d(TAG, "onPrimaryClipChanged");
ClipData clip = mClipboardManager.getPrimaryClip();
CharSequence mTextToWrite = clip.getItemAt(0).getText();
new RetrieveUrlTask().execute(mTextToWrite.toString());
}
};
mClipboardManager.addPrimaryClipChangedListener(
mOnPrimaryClipChangedListener);
}
showNotification();
Intent startintent = new Intent(BROADCAST_MESSAGE_INSTASHARE);
startintent.putExtra(INSTASHARE_MONITORING, true);
sendBroadcast(startintent);
break;
case GET_INFO:
boolean bmonitoring = (mOnPrimaryClipChangedListener != null);
Intent getinfo = new Intent(BROADCAST_MESSAGE_INSTASHARE);
getinfo.putExtra(INSTASHARE_MONITORING, bmonitoring);
sendBroadcast(getinfo);
break;
}
}
return START_STICKY;
}
示例4: createListener
import android.content.ClipboardManager; //导入方法依赖的package包/类
/**
* The implementation will be invoked in constructor.
* It should not assume the instance is fully initialized yet.
*
*/
abstract protected ClipboardManager.OnPrimaryClipChangedListener createListener();