Java Grundkurs

S

syntax Terror

Neues Mitglied
0
Soll mir fürs erste die CID der SD Card liefern ,
zuerst wird der CPU Typ bestimmt und dementsprechend dann die Abfrage gestartet
funktioniert einzeln auch schon aber alles zusammen da Bekomme ich nur einen Programmabsturz
Kann mir bette jemand bei meinen Vorhaben helfen ich habe arge Probleme mit den Java Klasssen
Optimieren lässt sich das ganze sicher auch noch

(der Code ist sonst eig besser Formatiert)

Abfrage

Code:
class Main extends Activity {
//    private SysUtils Syst;

  private SdCard Sd;
  @Override
  publicvoid onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  // Syst = new SysUtils();
  Sd = new SdCard();
  findViewById(R.id.btnToast).setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v) {
     try
      {
        Toast.makeText(getApplicationContext(),"SID of MMC = " + Sd.ReadsdCID(), Toast.LENGTH_LONG).show();
      }
  catch(IOException e)
    {// TODO Auto-generated catch block
     e.printStackTrace();
    }
  } }
  );
}
  }

SdCard.java


Code:
class SdCard {

private SysUtils Syst;
    String Omap = ("/sys/devices/platform/mmci-omap-hs.0/mmc_host/mmc0/mmc0:aaaa/cid");
    String MSM = ("/sys/devices/platform/msm_sdcc.1/mmc_host/mmc0/mmc0:****/cid");
 public String ReadsdCID() throws IOException {
  String sd_cid = "";
   if (Syst.ifQualComm())
    {
    try
    {
    BufferedReader input = new BufferedReader(new FileReader(MSM));
    sd_cid = input.readLine();}
    catch (FileNotFoundException e)
     {
     // Toast.makeText(Con,e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
     }
    }
   if (Syst.ifOmap())
    {
    try
    {
    BufferedReader input = new BufferedReader(new FileReader(Omap));
    sd_cid = input.readLine();}
    catch (FileNotFoundException e)
     {
     // Toast.makeText(Con,e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
     }
    }
 return sd_cid;
 }
}

SysUtils.java

Code:
[B][COLOR=#7f0055]public[/COLOR][/B][SIZE=2] Boolean ifQualComm() {[/SIZE]
 [SIZE=2]        File theDir = [/SIZE][B][SIZE=2][SIZE=2]new[/SIZE][/SIZE][/B][SIZE=2] File([/SIZE][SIZE=2][SIZE=2]"/sys/devices/platform/msm_sdcc.1"[/SIZE][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][COLOR=#000000]         [/COLOR][B]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (theDir.exists())[/SIZE]
[SIZE=2]         {[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]         return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];          [/SIZE]
[SIZE=2]         }             [/SIZE]
         [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];[/SIZE] 
[SIZE=2]        }[/SIZE]
 
 
 
 
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Boolean ifOmap() {[/SIZE]
[SIZE=2]        File theDir = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] File([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"/sys/devices/platform/mmci-omap-hs.0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
        [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (theDir.exists()){[/SIZE]
        [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];          [/SIZE]
        [SIZE=2]}             [/SIZE]
        [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];[/SIZE] 
[SIZE=2]        }[/SIZE]
 
[SIZE=2]}[/SIZE]
 
naja wäre interessant, welchen fehler es gibt => logcat
 
Sorry das die Antwort solange gedauert hat hatte nicht mehr erwartet das jemand antwortet:thumbsup:

04-15 23:20:02.636: WARN/dalvikvm(26025): threadid=3: thread exiting with uncaught exception (group=0x4001e280)
04-15 23:20:02.646: ERROR/AndroidRuntime(26025): Uncaught handler: thread main exiting due to uncaught exception
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): java.lang.NullPointerException
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.formation.toasts.SdCard.ReadsdCID(SdCard.java:15)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.formation.toasts.Main$1.onClick(Main.java:26)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.View.performClick(View.java:2365)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.View.onTouchEvent(View.java:4180)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.widget.TextView.onTouchEvent(TextView.java:6728)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.View.dispatchTouchEvent(View.java:3710)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:894)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:894)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:894)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:894)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1116)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.app.Activity.dispatchTouchEvent(Activity.java:2142)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.view.ViewRoot.handleMessage(ViewRoot.java:1739)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.os.Looper.loop(Looper.java:136)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at android.app.ActivityThread.main(ActivityThread.java:4425)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at java.lang.reflect.Method.invoke(Method.java:521)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-15 23:20:02.656: ERROR/AndroidRuntime(26025): at dalvik.system.NativeStart.main(Native Method)
04-15 23:20:02.676: ERROR/ActivityManager(213): SIGNAL_QUIT: to crashed process 26025
 

Ähnliche Themen

D
Antworten
23
Aufrufe
2.510
Data2006
D
L
Antworten
4
Aufrufe
1.329
lonnie9020
L
M
  • maksimilian
Antworten
4
Aufrufe
986
maksimilian
M
Zurück
Oben Unten