Qt/QML App for Friendiqa
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alarmandroid.cpp 4.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // This file is part of Friendiqa
  2. // https://git.friendi.ca/lubuwest/Friendiqa
  3. // Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // In addition, as a special exception, the copyright holders give
  11. // permission to link the code of portions of this program with the
  12. // OpenSSL library under certain conditions as described in each
  13. // individual source file, and distribute linked combinations including
  14. // the two.
  15. //
  16. // You must obey the GNU General Public License in all respects for all
  17. // of the code used other than OpenSSL. If you modify file(s) with this
  18. // exception, you may extend this exception to your version of the
  19. // file(s), but you are not obligated to do so. If you do not wish to do
  20. // so, delete this exception statement from your version. If you delete
  21. // this exception statement from all source files in the program, then
  22. // also delete it here.
  23. //
  24. // This program is distributed in the hope that it will be useful,
  25. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. // GNU General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU General Public License
  30. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. //#include <QtAndroidExtras/QAndroidJniObject>
  32. //#include <QtAndroidExtras/QAndroidJniEnvironment>
  33. #include "alarm.h"
  34. #include <QtCore/QDebug>
  35. #include "AndroidNative/systemdispatcher.h"
  36. ALARM *ALARM::instance()
  37. {
  38. static ALARM alarm;
  39. return &alarm;
  40. }
  41. ALARM::ALARM(QObject *parent) : QObject(parent){}
  42. void ALARM::setAlarm(int interval)
  43. {
  44. qDebug() << interval;
  45. QVariantMap message;
  46. message["value"] = interval;
  47. AndroidNative::SystemDispatcher::instance()->loadClass("androidnative.Util");
  48. AndroidNative::SystemDispatcher::instance()->dispatch("androidnative.Util.setSchedule", message);
  49. //AndroidNative::SystemDispatcher::instance()->dispatch("androidnative.Util.stopService", message);
  50. // auto activity = QtAndroid::androidActivity();
  51. // auto packageManager = activity.callObjectMethod("getPackageManager",
  52. // "()Landroid/content/pm/PackageManager;");
  53. // auto activityIntent = packageManager.callObjectMethod("getLaunchIntentForPackage",
  54. // "(Ljava/lang/String;)Landroid/content/Intent;",
  55. // activity.callObjectMethod("getPackageName",
  56. // "()Ljava/lang/String;").object());
  57. // auto pendingIntent = QAndroidJniObject::callStaticObjectMethod("android/app/PendingIntent", "getActivity",
  58. // "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;",
  59. // activity.object(), jint(0), activityIntent.object(),
  60. // QAndroidJniObject::getStaticField<jint>("android/content/Intent",
  61. // "FLAG_ACTIVITY_CLEAR_TOP"));
  62. // auto alarmManager = activity.callObjectMethod("getSystemService",
  63. // "(Ljava/lang/String;)Ljava/lang/Object;",
  64. // QAndroidJniObject::getStaticObjectField("android/content/Context",
  65. // "ALARM_SERVICE",
  66. // "Ljava/lang/String;").object());
  67. // alarmManager.callMethod<void>("set",
  68. // "(IJLandroid/app/PendingIntent;)V",
  69. // QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"),
  70. // jlong(QDateTime::currentMSecsSinceEpoch() + 100), pendingIntent.object());
  71. }