小编Pus*_*dra的帖子

如何在背景中的特定日期时间在swift中运行任务,无论应用程序是打开还是关闭

我正在处理报警应用程序,我需要在特定时间安排报警,我scheduleLocalNotification用于安排报警,它可以正常工作.但是我需要在触发警报之前运行到我的API服务器的请求.在该请求中,我想检查从API服务器返回的一些参数,如果满足某些条件.

如果任何人有一个在特定日期运行的方法 - swift的时间请帮助我

 func addAlarm (newAlarm: Alarm) {
    // Create persistent dictionary of data
    var alarmDictionary = NSUserDefaults.standardUserDefaults().dictionaryForKey(ALARMS_KEY) ?? Dictionary()
    // Copy alarm object into persistent data
    alarmDictionary[newAlarm.UUID] = newAlarm.toDictionary()
    // Save or overwrite data
    NSUserDefaults.standardUserDefaults().setObject(alarmDictionary, forKey: ALARMS_KEY)

    scheduleNotification(newAlarm, category: "ALARM_CATEGORY")
    scheduleNotification(newAlarm, category: "FOLLOWUP_CATEGORY")

}

    /* NOTIFICATION FUNCTIONS */
func scheduleNotification (alarm: Alarm, category: String) {
    let notification = UILocalNotification()
    notification.category = category
    notification.repeatInterval = NSCalendarUnit.Day
    switch category {
    case "ALARM_CATEGORY":
        notification.userInfo   = ["UUID": alarm.UUID] …
Run Code Online (Sandbox Code Playgroud)

iphone background-process ios uilocalnotification swift

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

如何创建列表视图的占位符。

您好,我正在寻找列表视图占位符的简单答案。如何在 android 中创建此类占位符。

请检查这张图片

请建议我什么是创建这样的好方法。我将非常感谢那个能给我答案的人。

android listview android-layout

5
推荐指数
0
解决办法
437
查看次数

Amazon aws 中不允许针对此资源使用指定的方法

伙计们,我可能错了,也可能没有错,但说真的,我正在努力解决 Amazon S3 存储桶中的文件上传问题。当我尝试满足该请求时,我收到以下错误。

MethodNotAllowed不允许针对此资源指定方法

上面的消息是下面的响应的类型。

<?xml version="1.0" encoding="UTF-8"?><Error><Code>MethodNotAllowed</Code
<Message>Thespecified method is not allowed against this resource.</Message>
<Method>POST</Method><ResourceType>OBJECT</ResourceType>
<RequestId>xxx</RequestId><HostId>xxxx</HostId></Error>
Run Code Online (Sandbox Code Playgroud)

上面的消息是完整的消息,下面是我编写的用于将文件上传到亚马逊 s3 服务器的代码。

public synchronized boolean uploadFile(String url, String name, File file) {
    HttpEntity entity = MultipartEntityBuilder.create()
            .addPart("file", new FileBody(file)).build();
    HttpPost request = new HttpPost(url);
    request.setEntity(entity);
    HttpClient client = HttpClientBuilder.create().build();
    try {
        HttpResponse response = client.execute(request);
        entity = response.getEntity();
        if (entity != null) {
            try (InputStream in_stream = entity.getContent()) {
                BufferedReader in = new BufferedReader(new InputStreamReader(in_stream));
                String inputLine;
                StringBuilder …
Run Code Online (Sandbox Code Playgroud)

java amazon-s3 amazon-web-services smartfoxserver

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

如何在原生android中嵌入多个统一模块?

我遇到了一个问题。这个问题已经有人问过了。但是这个问题没有答案。

问题相关视频

根据这个问题的标题。如何在原生android项目中集成多个unity模块或库。我遵循了很多程序。但是我没有得到这个问题的解决方案。根据UNITY TECHNOLOGY指令,我必须将统一库集成到我的项目中。我已经为两个 unityLibrary 完成了这个。对于第二个库,我必须更改包和类名。并让它发挥作用。完成所有这些更改后,我的项目构建成功并且编译没有任何错误。当我点击加载第一个游戏时,它正在加载第一个游戏。但是当我点击加载第二个游戏时,它也只加载了第一个游戏。

下面是我的 android studio 的截图。

在此处输入图片说明

我正在与您分享有关此的更多描述。

*里面app module有 2 Activity,命名为MainActivityand GameHolderActivity。下面是MainActivity.java.

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.btn1Click).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, GameHolderActivity.class);
            intent.putExtra("game", 1);
            startActivity(intent);
        }
    });
    findViewById(R.id.btn2Click).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent …
Run Code Online (Sandbox Code Playgroud)

c# java android unity-game-engine

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

检查模块类路径是否缺少 gradle 版本 7.0.1 或存在冲突的依赖项

我被这个问题困住了。我已将项目等级升级到 7.0.1 和 Kotlin 1.5.30。升级之前一切正常。但升级后,我开始为每个项目收到以下错误。甚至,我也尝试过创建新项目。我也面临着同样的问题。请检查下图。 在此输入图像描述

下面,我正在编写我的项目的所有文件。其中负责数据绑定和视图绑定。

项目基础build.gradle

buildscript {
  ext.kotlin_version = '1.5.30'
  repositories {
      google()
      mavenCentral()
  }
  dependencies {
      classpath "com.android.tools.build:gradle:7.0.1"
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  }
}
task clean(type: Delete) {
  delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

基于应用程序的 build.gradle 文件

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
}

android {
    compileSdk 30

    defaultConfig {
        applicationId "colour.moon"
        minSdk 21
        targetSdk 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11 …
Run Code Online (Sandbox Code Playgroud)

data-binding android gradle kotlin android-viewbinding

5
推荐指数
0
解决办法
1185
查看次数

如何在应用程序处于后台时打开特定视图控制器on didReceiveRemoteNotification

我正在实现一个警报,我从服务器获取pushNotification,我收到完美的推送通知,它在前台模式下工作正常,但当应用程序进入后台时,它只获得推送通知,但没有加载我要加载的视图

请查看下面的代码

func registerForPushNotifications(application: UIApplication) {
    let notificationSettings = UIUserNotificationSettings(
        forTypes: [.Badge, .Sound, .Alert], categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
}
Run Code Online (Sandbox Code Playgroud)

这个方法来自 didFinishLaunchingWithOptions

func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    if notificationSettings.types != .None {
        application.registerForRemoteNotifications()
    }
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
    var tokenString = ""
    for i in 0..<deviceToken.length {
        tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
    }
    NSUserDefaults.standardUserDefaults().setObject(tokenString, forKey: "deviceToken")
}
Run Code Online (Sandbox Code Playgroud)

这是最后的方法

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
        print(userInfo)
        let storyboard = …
Run Code Online (Sandbox Code Playgroud)

ios swift xcode7

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

是否可以绘制两层饼图?

嗨,我正在尝试实现如下所示的图表。请查看图片,并帮助我找到合适的解决方案。在这里,我正在使用 MPAndroidChart库。

在此处输入图片说明

现在,我的饼图如下图所示。

在此处输入图片说明

我正在使用下面的xml

<com.github.mikephil.charting.charts.PieChart
    android:id="@+id/chart1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)

在Java中,我有这样的管理角度。

mChart.setMaxAngle(270f); // HALF CHART
mChart.setRotationAngle(135f);
Run Code Online (Sandbox Code Playgroud)

我仍然无法创建饼图的内线。我想要上面已经提到的图表。我怎么画那条线?

java android pie-chart mpandroidchart

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

C语言中有什么函数可以转换十进制数的基数?

我想知道C语言中是否有任何函数可以将十进制数二进制或十进制的基数转换为十六进制等。

c

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