本文整理匯總了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();