بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
مشکل : ایجاد Shortcut در Home Screen
باسلام و خسته نباشید !!
دوستان من از این تابع واسه ایجاد کردن shortcut در صفحه استفاده میکنم، اما نمیدونم این تابع رو کجا باید صدا بزنم تا موقع نصب ایجاد بشه و موقع پاک شدن برنامه، shortcut هم پاک بشه !!!؟
کد :
private void addShortcut() {
//Adding shortcut for MainActivity
//on Home screen
Intent shortcutIntent = new Intent(getApplicationContext(),
Main_book.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "myapp");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(),
R.drawable.ic_launcher));
addIntent
.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
private void removeShortcut() {
//Deleting shortcut for MainActivity
//on Home screen
Intent shortcutIntent = new Intent(getApplicationContext(),
Main_book.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "myapp");
addIntent
.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال
Mim
11 سال پیش
0
0
سلام
این لینک رو ببینید: http://viralpatel.net/blogs/android-install-uninstall-shortcut-example
با مثال توضیح داده و کامله.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .