6
현재 Android 앱에서 작업 중이므로 프로그램에 홈 화면의 바로 가기를 작성합니다. 다음과 같은 것 :Android 시작 프로그램의 홈 화면에서 특정 페이지에 프로그래밍 방식으로 바로 가기를 작성하려면 어떻게해야합니까?
Intent shortcutIntent = new Intent();
shortcutIntent.setClassName(ai.packageName, ai.name);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.addCategory(Intent.ACTION_PICK_ACTIVITY);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName);
BitmapDrawable bd=(BitmapDrawable)(res.get(app_id).activityInfo.loadIcon(p).getCurrent());
Bitmap newbit;
newbit=bd.getBitmap();
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newbit);
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
context.sendBroadcast(intent);
(사실이 솔루션을 지적하는 StackOverflow 게시물이었습니다).
어쨌든 에뮬레이터에서 앱을 실행하면 바로 가기가 왼쪽에서 다섯 번째 페이지 (2.3 홈 화면)에 기록됩니다. 후속 실행은 홈 화면의 왼쪽에서 네 번째 페이지에 바로 가기를 씁니다.
제 질문은 이것입니다 : 바로 가기를 중앙 페이지 나 첫 번째 페이지 (예 : 앱 바로 가기를 보유하고있는 것으로 보이는 2 차원 배열의 인덱스 전달)에 쓰는 방법이 있습니까? API에서 뭔가가 누락 되었습니까?
감사합니다.
나는 두려웠다. 당신의 대답에 대해 좀 더 자세히 설명해 주시겠습니까? – subsecond
자세히 설명 할 사항은 없지만 Launcher에서는 바로 가기를 어디에서 선택할 것인지 선택할 수 없습니다. 이것을 달성 할 API가 없습니다. –
오케이. 이 방법으로 생성 된 바로 가기를 허용하고 작성 위치를 더 세밀하게 제어 할 수없는 것은 이상한 것처럼 보입니다. 나는 그 안에 유틸리티를 보지 않습니다. 그래도 고마워. 나는 다른 접근법을 시도해야 할 것이다. – subsecond