我的应用程序有一个基本的登录屏幕,一个外盒,里面有一些文本字段和按钮.我将框设置为填满屏幕.但是,在某些设备上,这个盒子会很大.我想为它设置最大宽度和高度.
如何为视图设置最大宽度和高度?
我想得到这样的当前时间戳:
636110767775716756?
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时:
NSDate().timeIntervalSince1970
Run Code Online (Sandbox Code Playgroud)
它返回一个这样的值:
1475491615.71278
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中,我有一个屏幕,用户可以单击不同类型的文件来查看和下载它们.但是,只有在用户通过网站登录后才能访问此屏幕.
我使用此方法使用我的URL启动Safari浏览器:
UIApplication.sharedApplication().openURL(NSURL(string: url)!)
Run Code Online (Sandbox Code Playgroud)
但是,用户被重定向到登录屏幕,因为他还没有被授权使用该网站.
我的问题是,如何将cookie或标题传递给Safari并使用这些URL启动URL?
在我的应用程序中,用户使用Web服务登录,Web服务返回授权密钥.在此之后,每个请求用户都使用此密钥完成.
我的问题是如何安全地存储这个密钥?我一直把它存储在SharedPreferences中,但这对我来说听起来不太安全.
如何定义一个静态字典并在 Java 中访问它。我在 iOS Swift 中这样做:
let pairs = [
"Name1": "Value1",
"Name2": "Value2"
]
print(pairs["Name1"]) // Value1
Run Code Online (Sandbox Code Playgroud)
如何在 Java 中做这样的事情?
我的应用程序有一个注册服务,用户可以自己注册。然而,有恶意的人可以编写一个脚本,在几秒钟内注册数千个帐户。
我的后端开发人员建议我们在移动应用程序中使用验证码。但是我没有看到任何使用验证码的应用程序,它们的用户体验很差。
我的问题是如何防止此类攻击并保护我们应用程序中的服务?
我创建了一个里面BottomSheetDialog有一个GridView。当BottomSheetDialog被打开,你可以滚动下来正常。这样做会使BottomSheetDialog扩展到全屏并GridView正常向下滚动。
但是,当用户尝试向上滚动时;而不是向上滚动GridView,BottomSheetDialog缩小并关闭。
我想要的是能够在GridView不BottomSheetDialog改变尺寸的情况下上下滚动。
怎么做?
我的代码:
final BottomSheetDialog dialog = new BottomSheetDialog(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.grid, null);
dialog.setContentView(view);
Run Code Online (Sandbox Code Playgroud)
网格.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<GridView
android:background="#FFFFFF"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="3"
android:stretchMode="columnWidth"
android:horizontalSpacing="4dp"
android:verticalSpacing="4dp"
android:gravity="center"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我Firebase Cloud Messaging用来从我的服务器发送推送通知到我的Android应用程序.
当应用程序运行时,通知会堆叠,因为我将它们设置为我的组中的组FirebaseMessagingService.这很好.
但是,当应用程序未运行时,通知不会堆叠,并且每个通知都会单独显示.这不好.
即使应用程序未运行,如何确保通知堆叠?
这是我的FirebaseMessagingService样子:
public class MyFcmListenerService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
RemoteMessage.Notification notification = remoteMessage.getNotification();
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notif_white)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.notif_white))
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(notification.getBody())
.setAutoCancel(true)
.setPriority(2)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setGroup("1")
.setGroupSummary(true)
.setOnlyAlertOnce(true);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 , notificationBuilder.build());
}
}
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有两个struct数组,我想从其中一个中删除常用项.我的结构:
struct PeopleSelectItem {
var name = ""
var id = ""
var added = false
}
Run Code Online (Sandbox Code Playgroud)
我的阵列:
var people : [PeopleSelectItem] = []
var selectedPeople : [PeopleSelectItem] = []
Run Code Online (Sandbox Code Playgroud)
我想从people数组中删除项目(如果它们存在(通过id比较)在selectedPeople数组上).
我尝试了几个数组过滤和转换设置,但没有一个工作.我能在这做什么?
谢谢!
android ×4
ios ×4
swift ×3
java ×2
security ×2
autolayout ×1
bottom-sheet ×1
captcha ×1
firebase ×1
mobile ×1
objective-c ×1
time ×1
timestamp ×1