File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed
android_debug_lib/src/main
java/com/itlgl/android/debuglib Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ <h4>版本号:${appVersionCode}</h4>
2424 data . append ( 'param' , apdu ) ;
2525 $ . ajax ( {
2626 type :'post' ,
27- url :'/' ,
27+ url :'/message ' ,
2828 cache : false ,
2929 processData : false ,
3030 contentType : false ,
@@ -50,7 +50,7 @@ <h4>版本号:${appVersionCode}</h4>
5050 data . append ( 'param' , text ) ;
5151 $ . ajax ( {
5252 type :'post' ,
53- url :'/' ,
53+ url :'/message ' ,
5454 cache : false ,
5555 processData : false ,
5656 contentType : false ,
@@ -76,7 +76,7 @@ <h4>版本号:${appVersionCode}</h4>
7676 data . append ( 'param' , command ) ;
7777 $ . ajax ( {
7878 type :'post' ,
79- url :'/' ,
79+ url :'/message ' ,
8080 cache : false ,
8181 processData : false ,
8282 contentType : false ,
@@ -102,7 +102,7 @@ <h4>版本号:${appVersionCode}</h4>
102102 data . append ( 'param' , text ) ;
103103 $ . ajax ( {
104104 type :'post' ,
105- url :'/' ,
105+ url :'/message ' ,
106106 cache : false ,
107107 processData : false ,
108108 contentType : false ,
Original file line number Diff line number Diff line change @@ -190,12 +190,7 @@ private Response responsePostMessage(IHTTPSession session) throws Exception {
190190 return responseTextError ("uri=" + strUri + ",param is null!" );
191191 }
192192
193- //获取剪贴板管理器:
194- ClipboardManager cm = (ClipboardManager ) context .getSystemService (Context .CLIPBOARD_SERVICE );
195- // 创建普通字符型ClipData
196- ClipData mClipData = ClipData .newPlainText (param , param );
197- // 将ClipData内容放到系统剪贴板里。
198- cm .setPrimaryClip (mClipData );
193+ AppUtils .copyToClipboardThread (context , param );
199194
200195 return responseText ("copy '" + param + "' to mobile clipboard" );
201196 } else if ("sendMessage" .equalsIgnoreCase (method )) {
Original file line number Diff line number Diff line change 11package com .itlgl .android .debuglib .utils ;
22
3+ import android .content .ClipData ;
4+ import android .content .ClipboardManager ;
35import android .content .Context ;
46import android .content .pm .ApplicationInfo ;
57import android .content .pm .PackageInfo ;
68import android .content .pm .PackageManager ;
79import android .graphics .Bitmap ;
810import android .graphics .drawable .BitmapDrawable ;
911import android .graphics .drawable .Drawable ;
12+ import android .os .Handler ;
13+ import android .os .Looper ;
1014
1115public class AppUtils {
1216
@@ -105,4 +109,19 @@ public static synchronized Bitmap getBitmap(Context context) {
105109 return bm ;
106110 }
107111
112+ public static Handler MAIN_HANDLER = new Handler (Looper .getMainLooper ());
113+
114+ public static void copyToClipboardThread (final Context context , final String text ) {
115+ MAIN_HANDLER .post (new Runnable () {
116+ @ Override
117+ public void run () {
118+ //获取剪贴板管理器:
119+ ClipboardManager cm = (ClipboardManager ) context .getSystemService (Context .CLIPBOARD_SERVICE );
120+ // 创建普通字符型ClipData
121+ ClipData mClipData = ClipData .newPlainText (text , text );
122+ // 将ClipData内容放到系统剪贴板里。
123+ cm .setPrimaryClip (mClipData );
124+ }
125+ });
126+ }
108127}
You can’t perform that action at this time.
0 commit comments