It should be something easy to do, but these commands return error when I try to convert a String to integer:
Intent recibir = getIntent();
String nombre = recibir.getStringExtra("hora_inicio");
int numero=0;
try {
numero = Integer.parseInt(nombre);
} catch(NumberFormatException nfe) {
nfe.printStackTrace();
}
Toast.makeText(this, numero, Toast.LENGTH_SHORT).show();
Android monitor returns this error:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.cristobal.policlinica, PID: 11025 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.cristobal.policlinica/com.example.cristobal.policlinica.CalendarActivity}: android.content.res.Resources$NotFoundException: String resource ID 0x9 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.content.res.Resources$NotFoundException: String resource 0x9 at android.content.res.Resources.getText(Resources.java:312) at android.widget.Toast.makeText(Toast.java:286) at com.example.cristobal.policlinica.CalendarActivity.onCreate(CalendarActivity.java:31) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
thanks in advance
Resources$NotFoundException: String resource ID
And setToast.makeText(this, ""+numero, Toast.LENGTH_SHORT).show();
– IntelliJ AmiyaToast.makeText(this, String.valueOf(numero), Toast.LENGTH_SHORT).show();
– Kush