{"id":1023,"date":"2017-05-31T11:49:45","date_gmt":"2017-05-31T02:49:45","guid":{"rendered":"http:\/\/yoonhada.com\/wp\/?p=1023"},"modified":"2023-12-27T00:11:58","modified_gmt":"2023-12-26T15:11:58","slug":"%ec%84%a4%ec%b9%98%ec%8b%9c-%ec%88%8f%ec%bb%b7-%eb%a7%8c%eb%93%a4%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/yoonhada.com\/?p=1023","title":{"rendered":"\uc124\uce58\uc2dc \uc20f\ucef7 \ub9cc\ub4e4\uae30"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"enlighter\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Note that a shortcut is created automagically if the app is installed via Play store.\n\/\/ Change \"APP_NAME\" by your app name. *MrObvious*\n\n\/*Manifest file - add this *\/\n&lt;uses-permission android:name=\"com.android.launcher.permission.INSTALL_SHORTCUT\" \/>\n\n\/* MainActivity.java *\/\npublic class MainActivity ... {\n    ...\n    private SharedPreferences appSettings;\n    ...\n\n    protected void onCreate(Bundle savedInstanceState) {\n        ...\n        ...\n        appSettings = getSharedPreferences(\"APP_NAME\", MODE_PRIVATE);\n        \/\/ Make sure you only run addShortcut() once, not to create duplicate shortcuts.\n        if(!appSettings.getBoolean(\"shortcut\", false)) {\n            addShortcut();\n        }\n    }\n\n    private void addShortcut() {\n        \/\/Adding shortcut for MainActivity\n        \/\/on Home screen\n        Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);\n        shortcutIntent.setAction(Intent.ACTION_MAIN);\n\n        Intent addIntent = new Intent();\n        addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);\n        addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, \"APP_NAME\");\n        addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,\n        Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));\n        addIntent.putExtra(\"duplicate\", false);\n        addIntent.setAction(\"com.android.launcher.action.INSTALL_SHORTCUT\");\n        getApplicationContext().sendBroadcast(addIntent);\n\n        SharedPreferences.Editor prefEditor = appSettings.edit();\n        prefEditor.putBoolean(\"shortcut\", true);\n        prefEditor.commit();\n    }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[83],"tags":[17],"class_list":["post-1023","post","type-post","status-publish","format-standard","hentry","category-archive","tag-android"],"_links":{"self":[{"href":"http:\/\/yoonhada.com\/index.php?rest_route=\/wp\/v2\/posts\/1023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yoonhada.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yoonhada.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yoonhada.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yoonhada.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1023"}],"version-history":[{"count":2,"href":"http:\/\/yoonhada.com\/index.php?rest_route=\/wp\/v2\/posts\/1023\/revisions"}],"predecessor-version":[{"id":2103,"href":"http:\/\/yoonhada.com\/index.php?rest_route=\/wp\/v2\/posts\/1023\/revisions\/2103"}],"wp:attachment":[{"href":"http:\/\/yoonhada.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yoonhada.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1023"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yoonhada.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}