Click here to Skip to main content
15,900,461 members
Home / Discussions / Java
   

Java

 
SuggestionTHREADS Pin
Atulthecoder25-Aug-12 10:53
Atulthecoder25-Aug-12 10:53 
GeneralRe: THREADS Pin
pasztorpisti25-Aug-12 11:14
pasztorpisti25-Aug-12 11:14 
GeneralRe: THREADS Pin
Richard MacCutchan25-Aug-12 21:33
mveRichard MacCutchan25-Aug-12 21:33 
QuestionRead Barcode from mobile and show the product type Pin
Sahil Mahajan Mj24-Aug-12 22:47
Sahil Mahajan Mj24-Aug-12 22:47 
AnswerRe: Read Barcode from mobile and show the product type Pin
TorstenH.25-Aug-12 0:58
TorstenH.25-Aug-12 0:58 
GeneralRe: Read Barcode from mobile and show the product type Pin
Sahil Mahajan Mj25-Aug-12 1:17
Sahil Mahajan Mj25-Aug-12 1:17 
GeneralRe: Read Barcode from mobile and show the product type Pin
TorstenH.27-Aug-12 3:07
TorstenH.27-Aug-12 3:07 
QuestionAlarm in android app Pin
ljpv1421-Aug-12 12:09
ljpv1421-Aug-12 12:09 
I tried to create and androip app where a user inputs a medicine, qty and hours(per day). After pressing save, the information will be stored at a file and an alarm should be created to trigger every hour (user spicified/hours). The application always stops and there seems to be a lot of error.

Here is how I create it:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_medicinereminder);

MedName = (EditText) findViewById(R.id.MedName);
Qty = (EditText) findViewById(R.id.MedQty);
NoOfHours = (EditText) findViewById(R.id.MedHours);
noh = Integer.parseInt((NoOfHours.getText()).toString());

Button SaveRem = (Button) findViewById(R.id.createRem);

SaveRem.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

try
{
String filePath = getFilesDir().getPath().toString() + "/MedRem.txt";
File myFile = new File(filePath);
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
myOutWriter.append(MedName.getText() + "\n");
myOutWriter.append(Qty.getText() + "\n");
myOutWriter.append(NoOfHours.getText() + "\n");
myOutWriter.close();
fOut.close();

createAlarm(noh);

}
catch (Exception e)
{
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}

}

});
}


public void createAlarm(int noOfHours)
{
//Create an offset from the current time in which the alarm will go off.
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR,noOfHours);

try{
//Create a new PendingIntent and add it to the AlarmManager
Intent alarmIntent = new Intent(this, MyAlarmService.class);
alarmIntent.putExtra("nel.example.alarms1","My message");
PendingIntent pendingAlarmIntent = PendingIntent.getService(this, 0,
alarmIntent, 0);

AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

Calendar AlarmCal = Calendar.getInstance();
AlarmCal.setTimeInMillis(System.currentTimeMillis());
AlarmCal.set(Calendar.HOUR_OF_DAY, 0); // set user selection
AlarmCal.set(Calendar.MINUTE, 10); // set user selection
AlarmCal.set(Calendar.SECOND, 0);

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
AlarmCal.getTimeInMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES,
pendingAlarmIntent);

Toast.makeText(getBaseContext(),
"Medicine Reminder Saved'",
Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}


}

Here is the latest Catlog of my app:


08-22 05:44:29.710: E/Trace(625): error opening trace file: No such file or directory (2)
08-22 05:44:30.430: D/dalvikvm(625): GC_CONCURRENT freed 202K, 3% free 8202K/8455K, paused 28ms+11ms, total 97ms
08-22 05:44:30.430: D/dalvikvm(625): WAIT_FOR_CONCURRENT_GC blocked 70ms
08-22 05:44:30.550: D/dalvikvm(625): GC_FOR_ALLOC freed 250K, 6% free 8260K/8711K, paused 44ms, total 45ms
08-22 05:44:31.100: I/Choreographer(625): Skipped 90 frames! The application may be doing too much work on its main thread.
08-22 05:44:31.132: D/gralloc_goldfish(625): Emulator without GPU emulation detected.
08-22 05:55:55.740: D/AndroidRuntime(625): Shutting down VM
08-22 05:55:55.740: W/dalvikvm(625): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-22 05:55:55.780: E/AndroidRuntime(625): FATAL EXCEPTION: main
08-22 05:55:55.780: E/AndroidRuntime(625): java.lang.RuntimeException: Unable to start activity ComponentInfo{dr.droid/dr.droid.MedicineReminder}: java.lang.NumberFormatException: Invalid int: ""
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.os.Looper.loop(Looper.java:137)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-22 05:55:55.780: E/AndroidRuntime(625): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 05:55:55.780: E/AndroidRuntime(625): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 05:55:55.780: E/AndroidRuntime(625): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-22 05:55:55.780: E/AndroidRuntime(625): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-22 05:55:55.780: E/AndroidRuntime(625): at dalvik.system.NativeStart.main(Native Method)
08-22 05:55:55.780: E/AndroidRuntime(625): Caused by: java.lang.NumberFormatException: Invalid int: ""
08-22 05:55:55.780: E/AndroidRuntime(625): at java.lang.Integer.invalidInt(Integer.java:138)
08-22 05:55:55.780: E/AndroidRuntime(625): at java.lang.Integer.parseInt(Integer.java:359)
08-22 05:55:55.780: E/AndroidRuntime(625): at java.lang.Integer.parseInt(Integer.java:332)
08-22 05:55:55.780: E/AndroidRuntime(625): at dr.droid.MedicineReminder.onCreate(MedicineReminder.java:33)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.Activity.performCreate(Activity.java:5008)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-22 05:55:55.780: E/AndroidRuntime(625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-22 05:55:55.780: E/AndroidRuntime(625): ... 11 more
08-22 05:55:57.971: I/Process(625): Sending signal. PID: 625 SIG: 9


Thanks!
AnswerRe: Alarm in android app Pin
Peter_in_278021-Aug-12 12:43
professionalPeter_in_278021-Aug-12 12:43 
QuestionSOLID principle problem Pin
Neo1010121-Aug-12 7:36
Neo1010121-Aug-12 7:36 
AnswerRe: SOLID principle problem Pin
Nagy Vilmos21-Aug-12 7:57
professionalNagy Vilmos21-Aug-12 7:57 
QuestionObject parsing non-static Pin
Joshua Waring20-Aug-12 23:11
Joshua Waring20-Aug-12 23:11 
AnswerRe: Object parsing non-static Pin
Nagy Vilmos21-Aug-12 6:48
professionalNagy Vilmos21-Aug-12 6:48 
AnswerRe: Object parsing non-static Pin
jschell21-Aug-12 8:40
jschell21-Aug-12 8:40 
QuestionIs it a bug or featuere Pin
Amarap18-Aug-12 0:58
Amarap18-Aug-12 0:58 
AnswerRe: Is it a bug of featuer Pin
Manfred Rudolf Bihy18-Aug-12 2:11
professionalManfred Rudolf Bihy18-Aug-12 2:11 
AnswerRe: Is it a bug of featuer Pin
Gerben Jongerius18-Aug-12 2:12
Gerben Jongerius18-Aug-12 2:12 
AnswerRe: Is it a bug of featuer Pin
Eddy Vluggen18-Aug-12 2:28
professionalEddy Vluggen18-Aug-12 2:28 
AnswerRe: Is it a bug of featuer Pin
TorstenH.18-Aug-12 3:22
TorstenH.18-Aug-12 3:22 
AnswerRe: Is it a bug or featuere Pin
Gowtham Gutha15-Nov-12 7:25
Gowtham Gutha15-Nov-12 7:25 
Questionproblem while updating a file Pin
Namdeo Badhe17-Aug-12 7:07
Namdeo Badhe17-Aug-12 7:07 
Answerdouble post Pin
TorstenH.17-Aug-12 9:00
TorstenH.17-Aug-12 9:00 
Generalproblem while updating a text file in java Pin
Namdeo Badhe17-Aug-12 6:45
Namdeo Badhe17-Aug-12 6:45 
GeneralRe: problem while updating a text file in java Pin
Richard MacCutchan17-Aug-12 6:59
mveRichard MacCutchan17-Aug-12 6:59 
QuestionMessage Removed Pin
16-Aug-12 6:53
Member 936232116-Aug-12 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.