반응형
목적:
안드로이드의 쑛컷을 구현한다.
앱을 롱클릭했을때 바로가기가 보인다.
%shortcut.xml은 난독화에서 제외 시킬것.
구현방법:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application ... >
<activity android:name="Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
</application>
</manifest>
res/xml/shortcuts.xml
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="compose"
android:enabled="true"
android:icon="@drawable/compose_icon"
android:shortcutShortLabel="@string/compose_shortcut_short_label1"
android:shortcutLongLabel="@string/compose_shortcut_long_label1"
android:shortcutDisabledMessage="@string/compose_disabled_message1">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.example.myapplication"
android:targetClass="com.example.myapplication.ComposeActivity" >
<extra android:name="extra_key" android:value="extra_value" /> //인자 전달
</intent>
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="android.shortcut.conversation" />
<capability-binding android:key="actions.intent.CREATE_MESSAGE" />
</shortcut>
<!-- Specify more shortcuts here. -->
</shortcuts>
MainActivity.java
Intent intent = getIntent();
String extra_key = intent.getStringExtra("extra_key");
MyLog.i(TAG,"extra_key: "+extra_key);
참고자료:
[1] 바로가기 만들기, https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts?hl=ko
[2] 기능스미카, https://developer.android.com/guide/app-actions/action-schema?hl=ko#capability_schema
반응형
'안드로이드' 카테고리의 다른 글
[Android] WebView 에서 bridge(@javascriptIngerface)를 구현 (0) | 2023.01.05 |
---|---|
[안드로이드] WebView uri scheme 마켓 이동 (0) | 2022.12.06 |
[안드로이드] 앱 알림설정 on off 활성 비활성화 차단 방법 (0) | 2022.04.26 |
[안드로이드] 앱(패키지) 설치 유무 확인 (0) | 2022.04.15 |
[android] 위치 정보 서비스 GPS/Network LocationTracker (Kotlin) (0) | 2021.11.25 |