2017-10-09 1 views
1

내 애플은 minSdk = 21을 가지고 바로 가기 targetSdk = 26안드로이드 - 오류 응용 프로그램을 추가하는 동안은

내가의 첫 번째 활동에 <meta-data> 태그를 추가 한 응용 프로그램 바로 가기

을 설정하고 싶어 앱이 시작될 때 실행됩니다.
<activity android:name=".SignInActivity" 
      android:theme="@style/SubscriptionsTheme.NoActionBar"> 
      <intent-filter> 
       <category android:name="android.intent.category.LAUNCHER" /> 
       <action android:name="android.intent.action.MAIN"/> 
      </intent-filter> 
      <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/> 
     </activity> 

는 다음 나는 xml-v25 디렉토리를 만들고 그 안에이 shortcuts.xml 파일 : 나는 다음과 같은 오류가 얻을 응용 프로그램 빌드 할 때

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android" > 
    <shortcut 
     android:shortcutId="test" 
     android:icon="@drawable/plus" 
     android:shortcutShortLabel="test" 
     android:shortcutLongLabel="long test" > 

     <intent 
      android:action="android.intent.action.VIEW" 
      android:targetPackage="com.xxxxx.xxxxx.xxxxx" 
      android:targetClass="com.xxxxx.xxxxx.xxxxxx.main" /> 

    </shortcut> 
</shortcuts> 

가 :

Error:error: 'long test' is incompatible with attribute android:shortcutLongLabel (attr) reference. Error:error: 'test' is incompatible with attribute android:shortcutShortLabel (attr) reference. Error:'long test' is incompatible with attribute android:shortcutLongLabel (attr) reference.

+3

문자열 리소스 – Zoe

답변

2

희망이 도움이 . 자바에서 Manifest.xml

<shortcut 
     android:shortcutId="test" 
     android:icon="@drawable/plus" 
     android:shortcutShortLabel="@string/short_shortcut" 
     android:shortcutLongLabel="@string/long_shortcut" > 

에서이 문자열의

strings.xml 

<string name="long_shortcut">long test</string> 
    <string name="short_shortcut">test</string> 

사용 참조 또한 setLongLabel (CharSequence longLabel)ShortcutInfo.BuildersetShortLabel(CharSequence)를 사용하여이 작업을 할당 할 수 있습니다.

+0

을 사용해 주셔서 감사합니다. 이것은 효과가 있었다. 왜 테스트를 위해 하드 코딩하지 않아야하는지 모르겠다해도 – Daniele

+3

Manifest는 fb_id, fabric_id 또는 map_id로 작업 할 때 모든 ID (ID)에 대한 참조를 선호합니다. /'String' (문자열을 직접 지정할 때). –

관련 문제