I create popup window in service like this
public class ChatService extends Service { WindowManager mWindowMgr; WindowManager.LayoutParams mWinMgrParam; View mView; @Override public void onCreate() { LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); mView = inflater.inflate(R.layout.chat_window, null); mWinMgrParam = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE;, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); mWindowMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE); mWindowMgr.addView(mView, mWinMgrParam); } }
But not open copy&paste context view in edittext and textview like this. please see this attachment img. string was selected but not popup "copy, paste" context view...
I want to show copy and paste popup in my service view. How to do that?
chat_service.xml
<TextView android:id="@+id/tvContents" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@color/black_overlay_150" android:maxLines="50" android:scrollbars="vertical" android:textColor="@color/white" android:textIsSelectable="true" /> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:background="@color/green_light"> <TextView android:id="@+id/tvNickName" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:text="nickname" android:textSize="14sp" /> <EditText android:id="@+id/etUserInput" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:selectAllOnFocus="true" android:singleLine="true" android:textSize="14sp" />
AndroidManifest.xml
<service android:permission="android.permission.SYSTEM_ALERT_WINDOW" android:enabled="true" android:name=".talk.ChatService"> </service>