小编Ani*_*ake的帖子

Smack"必须有本地(用户)JID设置"错误

无法理解为什么会出现此错误并且应用程序崩溃.

低于错误:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.studyboard/com.studyboard.ChatMessageActivity}: java.lang.IllegalArgumentException: Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2493)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2555)
       at android.app.ActivityThread.access$800(ActivityThread.java:176)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:194)
       at android.app.ActivityThread.main(ActivityThread.java:5576)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
Caused by java.lang.IllegalArgumentException: Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once
       at org.jivesoftware.smack.filter.IQReplyFilter.<init>(IQReplyFilter.java:94)
       at org.jivesoftware.smack.AbstractXMPPConnection.createPacketCollectorAndSend(AbstractXMPPConnection.java:690) …
Run Code Online (Sandbox Code Playgroud)

android ejabberd smack

10
推荐指数
1
解决办法
1826
查看次数

想在Android中访问Power Button事件

   i=0;
   public boolean onKeyDown(int keyCode, KeyEvent event) {
    System.out.println("In Key Down Method." + event.getKeyCode());
    if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) {
        i++;
        System.out.println("Power button pressed.");
        if (i == 2) {
            System.out.println("Power button pressed continuoulsy 3 times.");
            Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show();
        } else {
            System.out.println("Power button pressed continuoulsy " + i + " times.");
            Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show();
        }
    }
    return super.onKeyDown(keyCode, event);
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用上面的代码访问电源按钮事件.它适用于Volume_Up和Volume_Down键,但不适用于电源/锁定按钮.为什么会发生?建议一些示例或代码.

android android-event

7
推荐指数
2
解决办法
9234
查看次数

更新通知栏上现有通知的通知内容,如Android中的Whatspp,Gmail等

当我观察Whats应用程序和gmail通知时,它们会自动更新该应用程序的现有通知,而无需创建新的通知。那么我该如何实现呢?在此处输入图片说明

我已经创建了一个如上图所示的通知。

  • 那时创建通知时,有四个消息。

  • 因此,当我收到第五条消息时,它应该附加现有通知的内容,如红色图像中所示。

请建议我在Gmail等应用中使用哪些方法?

我该如何实现?

notifications android android-notifications

5
推荐指数
1
解决办法
679
查看次数

使用我的自定义 UI 进行 Braintree 集成(无 Paypal 选项)

在不使用 Braintree Drop-In UI 的情况下,我想使用我的自定义 UI 来接受用户的信用卡详细信息并验证 Android 中的用户付款。请向我建议任何可以帮助我创建自定义 UI 的教程或示例。

android braintree

4
推荐指数
1
解决办法
3874
查看次数

尝试充气自定义布局时,Android Snackbar不会占用全宽

我正在尝试使用我的自定义布局更改快餐栏,但自定义布局不会占用小吃店的全宽.为什么?

这是我的代码: -

        CoordinatorLayout snackbarCoordinatorLayout;

        snackbarCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.snackbarCoordinatorLayout);
        RelativeLayout objRelativeLayout = new RelativeLayout(mContext);
        RelativeLayout.LayoutParams objLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        // Create the Snackbar
        final Snackbar snackbar = Snackbar.make(snackbarCoordinatorLayout, "", Snackbar.LENGTH_INDEFINITE);
        // Get the Snackbar's layout view
        Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();

        TextView textView = (TextView) layout.findViewById(android.support.design.R.id.snackbar_text);
        textView.setVisibility(View.INVISIBLE);

        LayoutInflater objLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View snackView = objLayoutInflater.inflate(R.layout.snackbar_layout, null);// use the parent ViewGroup instead of null        // Configure the view

        Button btnInvite = (Button) snackView.findViewById(R.id.btn_invite_snackbar);
        Button btnCancel = (Button) snackView.findViewById(R.id.btn_close_snackbar);

        btnInvite.setOnClickListener(new …
Run Code Online (Sandbox Code Playgroud)

android layout-inflater android-snackbar

3
推荐指数
1
解决办法
3703
查看次数

反应本机slice()函数未定义错误

我想更新我的列表视图行,因为我正尝试对列表视图数据源进行切片,但其引发以下错误:

this.state.dataSource.slice不是函数。(在“ this.state.dataSource.slice()”中,“ this.state.dataSource.slice”未定义)

这是我的代码:

let newArray = this.state.dataSource.slice();
newArray[indexToUpdate] = {
  //Here I am updating my values.
};
this.setState({
  dataSource: this.state.dataSource.cloneWithRows(newArray),
});
Run Code Online (Sandbox Code Playgroud)

让我知道代码中是否有错误或做错了什么。

react-native react-native-listview react-native-ios

1
推荐指数
1
解决办法
4894
查看次数

无法使用react-native-firebase在Android 8的前台接收通知

我无法仅在Android 8的Foreground中获得通知。也无法控制后台通知。 但是在低于8的Android版本上,可以在当前实现中正常工作。

遵循的步骤:-

  1. 将react-native-firebase插件版本5.0.0安装到应用程序中。
  2. 在Firebase控制台上创建了项目,并将google_service.json文件添加到android / app文件夹中。
  3. 在AndroidManifest中添加以下代码:-
     <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>
    <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService>
      <intent-filter>
          <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
      </intent-filter>
    </service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService"/>

   <receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/>
   <receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
      <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED"/>
          <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
          <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
   </receiver>
   <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/>
   <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="test_app"/>
Run Code Online (Sandbox Code Playgroud)
  1. 在App.js页面上添加了以下函数,并在componentDidMountMethod()中调用:
performNotificationOperations(){
  this.messageListener = firebase.messaging().onMessage((message: RemoteMessage) => {
    console.log("Message",message);
    alert("Notification Message Arrived");
    if(this.state.isLogin){
      const notification = new firebase.notifications.Notification()
                        .setNotificationId(message.messageId)
                        .setTitle(message.data.show_name)
                        .setBody(message.data.description)
                        .setData(message.data)
                        .android.setChannelId('test_app')
                        .android.setBigPicture(message.data.showImage)
                        .android.setPriority(firebase.notifications.Android.Priority.High);
      firebase.notifications().displayNotification(notification).catch(err => alert("Error On Message")); …
Run Code Online (Sandbox Code Playgroud)

android-notifications react-native android-8.0-oreo react-native-firebase

1
推荐指数
1
解决办法
2763
查看次数