use of android.text.ClipboardManager in project cw-advandroid by commonsguy.
the class IPClipper method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
String addr = getLocalIPAddress();
if (addr == null) {
Toast.makeText(this, "IP address not available -- are you online?", Toast.LENGTH_LONG).show();
} else {
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
cm.setText(addr);
Toast.makeText(this, "IP Address clipped!", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Log.e("IPClipper", "Exception getting IP address", e);
Toast.makeText(this, "Could not obtain IP address", Toast.LENGTH_LONG).show();
}
}
use of android.text.ClipboardManager in project cw-omnibus by commonsguy.
the class IPClipper method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
String addr = getLocalIPAddress();
if (addr == null) {
Toast.makeText(this, "IP address not available -- are you online?", Toast.LENGTH_LONG).show();
} else {
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
try {
cm.setText(addr);
Toast.makeText(this, "IP Address clipped!", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Exception clipping IP", e);
Toast.makeText(this, "Exception: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
Log.e("IPClipper", "Exception getting IP address", e);
Toast.makeText(this, "Could not obtain IP address", Toast.LENGTH_LONG).show();
}
finish();
}
use of android.text.ClipboardManager in project Signal-Android by WhisperSystems.
the class ConversationFragment method handleCopyMessage.
private void handleCopyMessage(final Set<MessageRecord> messageRecords) {
List<MessageRecord> messageList = new LinkedList<>(messageRecords);
Collections.sort(messageList, new Comparator<MessageRecord>() {
@Override
public int compare(MessageRecord lhs, MessageRecord rhs) {
if (lhs.getDateReceived() < rhs.getDateReceived())
return -1;
else if (lhs.getDateReceived() == rhs.getDateReceived())
return 0;
else
return 1;
}
});
StringBuilder bodyBuilder = new StringBuilder();
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
boolean first = true;
for (MessageRecord messageRecord : messageList) {
String body = messageRecord.getDisplayBody().toString();
if (body != null) {
if (!first)
bodyBuilder.append('\n');
bodyBuilder.append(body);
first = false;
}
}
String result = bodyBuilder.toString();
if (!TextUtils.isEmpty(result))
clipboard.setText(result);
}
use of android.text.ClipboardManager in project CircleDemo by Naoki2015.
the class CommentDialog method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.copyTv:
if (mCommentItem != null) {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(mCommentItem.getContent());
}
dismiss();
break;
case R.id.deleteTv:
if (mPresenter != null && mCommentItem != null) {
mPresenter.deleteComment(mCirclePosition, mCommentItem.getId());
}
dismiss();
break;
default:
break;
}
}
use of android.text.ClipboardManager in project AndroidSDK-RecipeBook by gabu.
the class Recipe014 method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String text;
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clipboard.hasText()) {
text = clipboard.getText().toString();
Log.d(TAG, text);
}
text = "sets by application!";
clipboard.setText(text);
}
Aggregations