我的 android 应用程序有问题。我想将 android 应用程序连接到在 jboss 7.1 上运行的 web 服务。当我创建异步任务以在我的 webservicde 上运行方法时,我在 logcat 中收到以下错误:
06-15 15:45:21.731: E/Trace(1958): error opening trace file: No such file or directory (2)
06-15 15:45:45.531: E/AndroidRuntime(1958): FATAL EXCEPTION: AsyncTask #1
06-15 15:45:45.531: E/AndroidRuntime(1958): java.lang.RuntimeException: An error occured while executing doInBackground()
06-15 15:45:45.531: E/AndroidRuntime(1958): at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.lang.Thread.run(Thread.java:856)
06-15 15:45:45.531: E/AndroidRuntime(1958): Caused by: java.lang.NullPointerException
06-15 15:45:45.531: E/AndroidRuntime(1958): at de.wifhm.se1.android.banking.OnlineBankingSystemStub.login(OnlineBankingSystemStub.java:52)
06-15 15:45:45.531: E/AndroidRuntime(1958): at de.wifhm.se1.android.LoginActivity$LoginLogoutTask.doInBackground(LoginActivity.java:118)
06-15 15:45:45.531: E/AndroidRuntime(1958): at de.wifhm.se1.android.LoginActivity$LoginLogoutTask.doInBackground(LoginActivity.java:1)
06-15 15:45:45.531: E/AndroidRuntime(1958): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-15 15:45:45.531: E/AndroidRuntime(1958): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-15 15:45:45.531: E/AndroidRuntime(1958): ... 3 more
android 清单如下所示:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.wifhm.se1.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:name=".OnlineBankingApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TransactionsActivity" android:label="@string/labelTransactions"></activity>
<activity android:name=".PrefsActivity" android:label="@string/labelPrefs"></activity>
</application>
</manifest>
这是我的 doInBackground 方法:
类 LoginLogoutTask 扩展 AsyncTask {
/**
* Diese Methode wird in einem nebenläufigen Thread ausgeführt (asynchron). Darum dürfen hier
* keine View-Elemente zugegriffen werden!
*/
@Override
protected String doInBackground(String... params) {
StringBuffer output = null;
if (LoginActivity.this.obsApp.getAngemeldeterKunde() == null) {
/* Login durchfuehren */
String username = LoginActivity.this.prefs.getString("username", "");
String password = LoginActivity.this.prefs.getString("password", "");
Kunde angemeldeterKunde = LoginActivity.this.obsApp.getObsStub().login(username, password);
LoginActivity.this.obsApp.setAngemeldeterKunde(angemeldeterKunde);
//Ergebnisausgabe:
output = new StringBuffer("Sie sind eingeloggt als " + angemeldeterKunde.getUserName() + ".\n\nIhre Konten:\n");
Set<Konto> konten = LoginActivity.this.obsApp.getObsStub().getEigeneKonten();
for (Konto konto : konten){
output.append("- Konto " + konto.getKontoNr() + "\n");
output.append("---Kontostand aktuell: " + LoginActivity.this.obsApp.getObsStub().getKontostand(konto.getKontoNr()) + "EUR\n");
}
}
else {
/* Logout durchfuehren */
LoginActivity.this.obsApp.getObsStub().logout();
LoginActivity.this.obsApp.setAngemeldeterKunde(null);
output = new StringBuffer("Bitte erneut einloggen.");
}
return output.toString();
}
有人能帮我吗?