Force close when try to Invoke method
1 - Make sure to add Internet permission to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
Note: uses-permission goes before application tag. i.e:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.awsapigatwway">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
2 - Make sure to execute your API Gateway call within an ASyncTask
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
ApiClientFactory factory = new ApiClientFactory();
final PetStoreClient client = factory.build(PetStoreClient.class);
Pet pet = client.petsPetIdGet("1");
Log.d(pet.getType(), String.valueOf(pet.getPrice()));
return null;
}
}.execute();
}
In this case, response should be seen on Logcat Debug.