无法理解为什么会出现此错误并且应用程序崩溃.
低于错误:
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) 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键,但不适用于电源/锁定按钮.为什么会发生?建议一些示例或代码.
在不使用 Braintree Drop-In UI 的情况下,我想使用我的自定义 UI 来接受用户的信用卡详细信息并验证 Android 中的用户付款。请向我建议任何可以帮助我创建自定义 UI 的教程或示例。
我正在尝试使用我的自定义布局更改快餐栏,但自定义布局不会占用小吃店的全宽.为什么?
这是我的代码: -
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) 我想更新我的列表视图行,因为我正尝试对列表视图数据源进行切片,但其引发以下错误:
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)
让我知道代码中是否有错误或做错了什么。
我无法仅在Android 8的Foreground中获得通知。也无法控制后台通知。 但是在低于8的Android版本上,可以在当前实现中正常工作。
遵循的步骤:-
Run Code Online (Sandbox Code Playgroud)<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)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")); …
android-notifications react-native android-8.0-oreo react-native-firebase