【问题标题】:mobilefirst push notification change android app_namemobilefirst 推送通知更改 android app_name
【发布时间】:2015-09-22 20:31:20
【问题描述】:

您好,我正在使用 mobilefirst 6.3 混合应用程序,从我的 string.xml 更改 app_name 时遇到问题。

我有我的混合名称应用程序 <string name="app_name">ASDFGHJK</string>,当我更改应用程序名称时,我需要将其更改为 <string name="app_name">ASDF GHJK</string>

当app在后台时,点击push不做任何事情,当im在app中时,receiver方法没有触发,怎么能在没有这个问题的情况下更改我的app名称?

【问题讨论】:

    标签: android push-notification ibm-mobilefirst


    【解决方案1】:

    res\values\strings.xml 中的app_name 值在内部用于创建 Intent 对象。因此,当应用关闭并且 GCMIntentService 收到消息时,它会创建一个动作为 <packagename>.<app_name> 的意图,并将其发送到通知服务以在通知栏中显示通知。

    这是在 AndroidManifest.xml 中使用的意图名称,用于指示应用必须在点击通知时启动:

    <activity android:name=".PushNotifications" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:screenOrientation="sensor"> 
        ....
        <intent-filter> 
            <action android:name="com.PushNotifications.PushNotifications.NOTIFICATION"/>  
            <category android:name="android.intent.category.DEFAULT"/> 
        </intent-filter> 
    

    所以现在如果app_name 更改为任何其他字符串,Intent 将在内部创建为com.PushNotifications.&lt;new_name&gt;
    但是 AndroidManifest.xml 仍然有例如com.PushNotifications.PushNotifications(在示例应用程序的情况下),因此应用程序不会启动,因为意图操作不同。

    要以不同的名称显示应用程序,请按以下步骤操作:

    1. 在 strings.xml 中,添加一个额外的 new_name_value
    2. 在 AndroidManifest.xml 中,用新的字符串名称修改标签

      <application android:label="@string/app_new_name" android:icon="@drawable/icon"> 
      <activity android:name=".PushNotifications" android:label="@string/app_new_name"...
      

    【讨论】:

    • 当我进入后台时,这不会改变我的应用程序上的图标名称和应用程序标题
    • 这个过程似乎给我们带来了麻烦,我们将清单包重命名为构建时间。但是 Push 无法启动,因为它使用上下文并尝试从错误的位置获取 app_name。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多