如何在 Android 中直接在软键盘下方看到应用程序?
How can I see the application directly underneath a soft keyboard in Android?
我正在开发一种软键盘,可以将数据(而非文本)通过管道传输到接收意图。有什么办法可以看到键盘当前覆盖的 application/activity 吗?我正在尝试预选意图操作选择器并开发自定义规则以使数据到达正确的位置。
我只是想针对这个问题回答我自己的问题。这是从堆栈顶部开始 returns activity 的代码。
public String PullTop() {
final PackageManager pm = getPackageManager();
//Get the Activity Manager Object
ActivityManager aManager =
(ActivityManager) self.getSystemService(ACTIVITY_SERVICE);
//Get the list of running Applications
List<ActivityManager.RunningAppProcessInfo> rapInfoList = aManager.getRunningAppProcesses();
//Iterate all running apps to get their details
for (ActivityManager.RunningAppProcessInfo rapInfo : rapInfoList) {
//error getting package name for this process so move on
if (rapInfo.pkgList.length == 0)
continue;
try {
PackageInfo pkgInfo = pm.getPackageInfo(rapInfo.pkgList[0], PackageManager.GET_ACTIVITIES);
Log.i("Package",pkgInfo.packageName);
return pkgInfo.packageName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.d("", "NameNotFoundException :" + rapInfo.pkgList[0]);
}
}
return null;
}
要将数据通过管道传输到正确的进程,只需检查 null 和:
intent.setPackage(PullTop());
我正在开发一种软键盘,可以将数据(而非文本)通过管道传输到接收意图。有什么办法可以看到键盘当前覆盖的 application/activity 吗?我正在尝试预选意图操作选择器并开发自定义规则以使数据到达正确的位置。
我只是想针对这个问题回答我自己的问题。这是从堆栈顶部开始 returns activity 的代码。
public String PullTop() {
final PackageManager pm = getPackageManager();
//Get the Activity Manager Object
ActivityManager aManager =
(ActivityManager) self.getSystemService(ACTIVITY_SERVICE);
//Get the list of running Applications
List<ActivityManager.RunningAppProcessInfo> rapInfoList = aManager.getRunningAppProcesses();
//Iterate all running apps to get their details
for (ActivityManager.RunningAppProcessInfo rapInfo : rapInfoList) {
//error getting package name for this process so move on
if (rapInfo.pkgList.length == 0)
continue;
try {
PackageInfo pkgInfo = pm.getPackageInfo(rapInfo.pkgList[0], PackageManager.GET_ACTIVITIES);
Log.i("Package",pkgInfo.packageName);
return pkgInfo.packageName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.d("", "NameNotFoundException :" + rapInfo.pkgList[0]);
}
}
return null;
}
要将数据通过管道传输到正确的进程,只需检查 null 和:
intent.setPackage(PullTop());