added copy text to JSInterface
This commit is contained in:
parent
bc63c47d47
commit
ce6e7561e5
@ -1,9 +1,12 @@
|
||||
package com.cradle.iitc_mobile;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.widget.Toast;
|
||||
|
||||
// provide communication between IITC script and android app
|
||||
public class IITC_JSInterface {
|
||||
@ -22,4 +25,13 @@ public class IITC_JSInterface {
|
||||
Uri.parse(s));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
// copy link to specific portal to android clipboard
|
||||
@JavascriptInterface
|
||||
public void copy(String s) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("Copied Text ", s);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(context, "copied to clipboard", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user