You need to show your code from line 12 and the part of the code where this constant is used. You are probably using functions not available in java8.
I make property of that and it got solved,
But the error is coming for this code now.
Error:
I think this is the last error.
Instead of pasting images, paste copied text.
private static final int RTC_WAKEUP = 0;
@SimpleProperty
public int RtcWakeup() {
return RTC_WAKEUP;
}
Should i need to change it
Yes, Yes because this:
@SimpleProperty
public static final int RTC_WAKEUP = 0;
won't work.
Also I mentioned the error above, I think this is the last error.
What is the IAlarmManager class? I don't know such a class, what package does it come from? Did AI generate your code?
Please show more code, as you're probably not using annotations correctly.
You should stop randomly pasting the codes from somewhere and expect them to work after adding annotations.
I would suggest you learn extreme basics of Java, it really helps a lot. Otherwise it would require countless discussion to correct your code. Which is beyond the scope of this topic related to Rush.
I am taking help with Jewel and he is giving good help,
He fixes my some of my code
but the fixed code is giving error.
The code he suggested.
public boolean isTimeZoneSet = false;
public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;
public AlarmManager(ComponentContainer container) {
super(container.$form());
this.container = container;
}
public static class IAlarmManager {
public static final int RTC_WAKEUP = 0;
public static final int RTC = 1;
public static final int ELAPSED_REALTIME_WAKEUP = 2;
public static final int ELAPSED_REALTIME = 3;
private final IAlarmManager mService;
AlarmManager(IAlarmManager service) {
mService = service;
}
}
My Full Code :
import android.content.Intent;
import android.os.RemoteException;
import javax.naming.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
public final IAlarmManager mService;
public class AlarmManager extends AndroidNonvisibleComponent implements Component {
public boolean isTimeZoneSet = false;
public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;
public AlarmManager(ComponentContainer container) {
super(container.$form());
this.container = container;
}
public static class IAlarmManager {
public static final int RTC_WAKEUP = 0;
public static final int RTC = 1;
public static final int ELAPSED_REALTIME_WAKEUP = 2;
public static final int ELAPSED_REALTIME = 3;
private final IAlarmManager mService;
AlarmManager(IAlarmManager service) {
mService = service;
}
}
@SimpleFunction(description="Schedule an alarm.")
public void set(int type, long triggerAtMillis, PendingIntent id) {
try {
mService.set(type, triggerAtMillis, id);
} catch (RemoteException ex) {
}
}
@SimpleFunction(description="Schedule a repeating alarm.")
public void setRepeating(int type, long triggerAtMillis,
long intervalMillis, PendingIntent id) {
try {
mService.setRepeating(type, triggerAtMillis, intervalMillis, id);
} catch (RemoteException ex) {
}
}
public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
public static final long INTERVAL_HALF_HOUR = 2*INTERVAL_FIFTEEN_MINUTES;
public static final long INTERVAL_HOUR = 2*INTERVAL_HALF_HOUR;
public static final long INTERVAL_HALF_DAY = 12*INTERVAL_HOUR;
public static final long INTERVAL_DAY = 2*INTERVAL_HALF_DAY;
@SimpleFunction(description="Available inexact recurrence intervals.")
public void setInexactRepeating(int type, long triggerAtMillis,
long intervalMillis, PendingIntent id) {
try {
mService.setInexactRepeating(type, triggerAtMillis, intervalMillis, id);
} catch (RemoteException ex) {
}
}
@SimpleFunction(description="Remove any alarms with a matching")
public void cancel(PendingIntent id) {
try {
mService.remove(id);
onAlarmCancelled(id);
} catch (RemoteException ex) {
}
}
@SimpleFunction(description="Set the system wall clock time.")
public void setTime(long millis) {
try {
mService.setTime(millis);
} catch (RemoteException ex) {
}
}
@SimpleEvent(description="Returns isTimeZoneSet")
public void AfterTimeZoneSet(boolean isTimeZoneSet){
EventDispatcher.dispatchEvent(this, "AfterTimeZoneSet", isTimeZoneSet);
}
@SimpleEvent(description="onCancelled Alarm")
public void onAlarmCancelled(string id){
EventDispatcher.dispatchEvent(this, "onAlarmCancelled", id);
}
@SimpleFunction(description="Set the system default time zone.")
public void setTimeZone(String timeZone) {
try {
mService.setTimeZone(timeZone);
isTimeZoneSet = true;
AfterTimeZoneSet(isTimeZoneSet);
} catch (RemoteException ex) {
}
}
@SimpleProperty(description="RTC_WAKEUP")
private static final int RTC_WAKEUP = 0;
public int TYPE_RTC_WAKEUP() {
return RTC_WAKEUP;
}
@SimpleProperty(description="RTC")
public static final int RTC = 1;
public int TYPE_RTC() {
return RTC;
}
@SimpleProperty(description="ELAPSED_REALTIME_WAKEUP")
public static final int ELAPSED_REALTIME_WAKEUP = 2;
public int TYPE_ELAPSED_REALTIME_WAKEUP() {
return ELAPSED_REALTIME_WAKEUP;
}
@SimpleProperty(description="ELAPSED_REALTIME")
public static final int ELAPSED_REALTIME = 3;
public int TYPE_ELAPSED_REALTIME() {
return ELAPSED_REALTIME;
}
}
import android.content.Intent;
import android.os.RemoteException;
import javax.naming.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
public final IAlarmManager mService;
public class AlarmManager extends AndroidNonvisibleComponent implements Component {
public boolean isTimeZoneSet = false;
public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;
public AlarmManager(ComponentContainer container) {
super(container.$form());
this.container = container;
}
public static class IAlarmManager {
public static final int RTC_WAKEUP = 0;
public static final int RTC = 1;
public static final int ELAPSED_REALTIME_WAKEUP = 2;
public static final int ELAPSED_REALTIME = 3;
private final IAlarmManager mService;
AlarmManager(IAlarmManager service) {
mService = service;
}
}
@SimpleFunction(description="Schedule an alarm.")
public void set(int type, long triggerAtMillis, PendingIntent id) {
try {
mService.set(type, triggerAtMillis, id);
} catch (RemoteException ex) {
}
}
@SimpleFunction(description="Schedule a repeating alarm.")
public void setRepeating(int type, long triggerAtMillis,
long intervalMillis, PendingIntent id) {
try {
mService.setRepeating(type, triggerAtMillis, intervalMillis, id);
} catch (RemoteException ex) {
}
}
public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
public static final long INTERVAL_HALF_HOUR = 2*INTERVAL_FIFTEEN_MINUTES;
public static final long INTERVAL_HOUR = 2*INTERVAL_HALF_HOUR;
public static final long INTERVAL_HALF_DAY = 12*INTERVAL_HOUR;
public static final long INTERVAL_DAY = 2*INTERVAL_HALF_DAY;
@SimpleFunction(description="Available inexact recurrence intervals.")
public void setInexactRepeating(int type, long triggerAtMillis,
long intervalMillis, PendingIntent id) {
try {
mService.setInexactRepeating(type, triggerAtMillis, intervalMillis, id);
} catch (RemoteException ex) {
}
}
@SimpleFunction(description="Remove any alarms with a matching")
public void cancel(PendingIntent id) {
try {
mService.remove(id);
onAlarmCancelled(id);
} catch (RemoteException ex) {
}
}
@SimpleFunction(description="Set the system wall clock time.")
public void setTime(long millis) {
try {
mService.setTime(millis);
} catch (RemoteException ex) {
}
}
@SimpleEvent(description="Returns isTimeZoneSet")
public void AfterTimeZoneSet(boolean isTimeZoneSet){
EventDispatcher.dispatchEvent(this, "AfterTimeZoneSet", isTimeZoneSet);
}
@SimpleEvent(description="onCancelled Alarm")
public void onAlarmCancelled(string id){
EventDispatcher.dispatchEvent(this, "onAlarmCancelled", id);
}
@SimpleFunction(description="Set the system default time zone.")
public void setTimeZone(String timeZone) {
try {
mService.setTimeZone(timeZone);
isTimeZoneSet = true;
AfterTimeZoneSet(isTimeZoneSet);
} catch (RemoteException ex) {
}
}
@SimpleProperty(description="RTC_WAKEUP")
private static final int RTC_WAKEUP = 0;
public int TYPE_RTC_WAKEUP() {
return RTC_WAKEUP;
}
@SimpleProperty(description="RTC")
public static final int RTC = 1;
public int TYPE_RTC() {
return RTC;
}
@SimpleProperty(description="ELAPSED_REALTIME_WAKEUP")
public static final int ELAPSED_REALTIME_WAKEUP = 2;
public int TYPE_ELAPSED_REALTIME_WAKEUP() {
return ELAPSED_REALTIME_WAKEUP;
}
@SimpleProperty(description="ELAPSED_REALTIME")
public static final int ELAPSED_REALTIME = 3;
public int TYPE_ELAPSED_REALTIME() {
return ELAPSED_REALTIME;
}
}
Why recreate something that has already been created? The source code is even provided. Start learning how to write extensions with something simple.
This one is different
Please also follow the naming conventions
And in case you need inspiration of some features to add, let me suggest to take a look at App Inventor Extensions: Alarm Manager | Pura Vida Apps
Taifun
Your full code is repeated, it is duplicated.
How can install andriod lib in VS Code? already searched alot.
why do you want to install android lib in VS Code?
To code by import android.*;
What class do you need exactly?
I don't feel it's possible because dev-deps don't contain android classes(what exactly I can remember from my past experience, as I have left extension development for sometime).
Any of the android to explore and code.
Is there any way.