Click here to Skip to main content
15,671,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
    public void handleResult(Result rawResult) {

        try {
            Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
        } catch (Exception e) {}
        int n = Integer.parseInt(rawResult.getText());
        showMessageDialog("Contents = " + rawResult.getText() + ", Format = " + rawResult.getBarcodeFormat().toString());
        Toast.makeText(getApplicationContext(), "vlaue is "+n, Toast.LENGTH_LONG).show();

What I have tried:

I am trying to convert string to integer i am using barcode app,i want to play with results but i first must convert to integer to do math with output!
This code gives me blanck withe screen without error and app crashes.
Updated 19-Feb-22 9:58am

Problem was the output is too long for integer i need to use long!
Share this answer
You also need to catch any exceptions thrown by Integer.parseInt (Java Platform SE 7 )[^].
Share this answer
Well ... for starters you are swallowing information that might be useful in finding out why:
catch (Exception e) {}
Try logging or displaying the error and exiting the method instead of hiding the problem.

You might get useful information ...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900