| 
| ¾Èµå·ÎÀÌµå ¾Û ÃÖÃÊ ½ÇÇà½Ã ¹ÙÅÁȸ鿡 ¾ÆÀÌÄÜ(Shortcut) »ý¼ºÇϱâ |  |  
|  |  |    | 9³â Àü |  | 
| ¾Èµå·ÎÀÌµå ¾Û ÃÖÃÊ ½ÇÇà½Ã ÀÚµ¿À¸·Î ¹ÙÅÁȸ鿡 ¾ÆÀÌÄÜ(shortcut)À» »ý¼ºÇØÁÖ´Â ÄÚµå´Ù. SharedPreferencesÀÇ "check"¶ó´Â ۸¦ ÀÌ¿ëÇØ
 ÇØ´ç ŰÀÇ value°¡ ºñ¾îÀÖÀ¸¸é(isEmpty()) shortcutÀ» »ý¼ºÇϰí,
 ±× ÈÄ¿¡´Â "exist"¶ó´Â value¸¦ ä¿öÁØ´Ù.
 
 SharedPreferences´Â ÀÌ·¸µí °£´ÜÇÑ ON/OFF ¼³Á¤¿¡ ÀÌ¿ëÇϸé ÁÁ´Ù.
 »ç¿ë¹ýµµ SQLDatabaseº¸´Ù °£´ÜÇϸç
 ¾ÛÀÌ »èÁ¦µÇÁö ¾Ê´Â ÇÑ °è¼Ó Áö¼ÓµÇ±â ¶§¹®ÀÌ´Ù.
 
 if(pref.getString("check","").isEmpty()) ÀÌÇÏ Äڵ带 ´Ù¸£°Ô ÇØ¼
 ¾Û ÃÖÃÊ ½ÇÇà½Ã ÃëÇÒ ¾×¼ÇÀ» ¸¶À½´ë·Î ²Ù¸çº¸´Â °Íµµ ÁÁ´Ù.
 
 //µ¥½ºÅ©Å¾ ¾ÆÀÌÄÜ »ý¼º
 public void createDesktopIcon() {
 SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE);
 pref.getString("check", "");
 
 if(pref.getString("check", "").isEmpty()){
 Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
 shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER);
 shortcutIntent.setClassName(this, getClass().getName());
 shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|
 Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
 Intent intent = new Intent();
 intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
 intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getResources().getString(R.string.app_name)); //¾Û À̸§
 intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
 Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); //¾Û ¾ÆÀÌÄÜ
 intent.putExtra("duplicate", false);
 intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
 sendBroadcast(intent);
 }
 
 SharedPreferences.Editor editor = pref.edit();
 editor.putString("check", "exist");
 editor.commit();
 }
 
 | 
 |  
|  ̵̧ : 373 | ̵̧
¸ñ·Ï |  |