我是一名移动开发人员,现在我正在开发一个连接到 SAP 后端的 Android 应用程序。
我需要从 BAPI 创建 MBO 并从这些 BAPI 读取数据
我设法从 BAPI_FLIGHT_GETLIST BAPI 创建 MBO
我将代码生成为 Android 代码,并创建了从该 MBO 读取数据的活动
当我在 android 设备上运行应用程序时,我在这一行得到以下错误
app.registerApplication(TIMEOUT);
谁能帮我解决这个错误?
我不明白我做错了什么
主要活动:
private static final int REQUEST_DETAIL = 99;
private static String USERNAME = "*********";
private static String PASSWORD = "**********";
private static String HOST = "************";
private static int PORT = 5001; // 2480
private static int sync_port = 2480;
private static int TIMEOUT = 600;
private GetFlightsListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeApplication();
}
private void initializeApplication() {
try {
// 1. App initialization
Application app = Application.getInstance();
app.setApplicationIdentifier("GetFlights");
app.setApplicationContext(MainActivity.this);
GetFlightsDB.setApplication(app);
GetFlightsDB.getSynchronizationProfile().setServerName(HOST);
// 2. Set connection properties
ConnectionProperties connProps = app.getConnectionProperties();
LoginCredentials loginCredentials = new LoginCredentials(USERNAME,PASSWORD);
connProps.setLoginCredentials(loginCredentials);
connProps.setServerName(HOST);
connProps.setPortNumber(PORT);
//3. App registration
if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED) {
app.registerApplication(TIMEOUT); // ERROR HAPPENS HERE <-----------
} else {
app.startConnection(TIMEOUT);
}
//4. Sync data
if (!GetFlightsDB.isSynchronized("default")) {
GetFlightsDB.disableChangeLog();
GetFlightsDB.synchronize(); // Initial Synchronize
SynchronizationGroup sg = GetFlightsDB.getSynchronizationGroup("default");
sg.setEnableSIS(true);
sg.save();
GetFlightsDB.synchronize();
}
GetFlightsDB.enableChangeLog();
}
finally {
Log.v("Finally", "Finally");
}
}
错误
Caused by: com.sybase.mobile.ApplicationRuntimeException: Error: 558 Message: 'Could not connect to server. Verify Relay Server URL Template'
E/AndroidRuntime(273): at com.sybase.mobile.Application.registerApplication(Application.java:409)
E/AndroidRuntime(273): at com.example.getflightsnative.MainActivity.initializeApplication(MainActivity.java:84)
清单文件:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.getflightsnative.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="7" >
</uses-sdk>