BackendlessFault{ code: ‘Internal client exception’, message: ‘Can’t create handler inside thread that has not called Looper.prepare()’ } While accessing the Backend less it responds as BackendlessFault{ code: ‘Internal client exception’, message: ‘Can’t create handler inside thread that has not called Looper.prepare()’ }, can help??
AsyncCallback<BackendlessCollection<testTable>> callback = new AsyncCallback<BackendlessCollection<testTable>>() {
@Override
public void handleResponse(BackendlessCollection<testTable> response) {
Log.e("", “” + response.getCurrentPage().size());
}
@Override
public void handleFault(BackendlessFault fault) {
Log.e("", “” + fault.toString());
}
};
Backendless.Persistence.of(testTable.class).find(callback);
Hi,
I’ve assigned your issue to our developer, he will contact with you soon to help you.
Regards,
Stanislav
What if you try invoking the API synchronously? Does it work?
BackendlessCollection<testTable> response = Backendless.Persistence.of(testTable.class).find();
Sorry that is also not working. I am getting that following exception.
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ BackendlessException{ code: ‘Internal client exception’, message: ‘null’ }
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.backendless.Invoker$SyncResponder.errorHandler(Invoker.java:127)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.backendless.core.responder.AdaptingResponder.errorHandler(AdaptingResponder.java:93)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at weborb.client.ioEngine.HttpIOEngine.send(HttpIOEngine.java:213)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at weborb.client.ioEngine.HttpIOEngine.invoke(HttpIOEngine.java:145)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at weborb.client.WeborbClient.invoke(WeborbClient.java:138)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.backendless.Invoker.invokeSync(Invoker.java:100)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.backendless.Persistence.find(Persistence.java:589)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.backendless.DataStoreFactory$1.find(DataStoreFactory.java:155)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.example.abdullahs.testbe.MainActivity.getData(MainActivity.java:34)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.example.abdullahs.testbe.MainActivity$1.onClick(MainActivity.java:27)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at android.view.View.performClick(View.java:5198)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at android.view.View$PerformClick.run(View.java:21147)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:739)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at android.os.Looper.loop(Looper.java:148)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5417)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at java.lang.reflect.Method.invoke(Native Method)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-22 00:53:09.837 1841-1841/com.example.abdullahs.testbe W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
and also it try with the following code it says that…
new Thread(new Runnable() {
public void run() {
// synchronous backendless API call here:
try {
BackendlessCollection<testTable> response = Backendless.Persistence.of(testTable.class).find();
response.getCurrentPage();
} catch (BackendlessException e) {
e.printStackTrace();
}
}
}).start();
BackendlessException{ code: ‘Internal client exception’, message: ‘Can’t create handler inside thread that has not called Looper.prepare()’ }
HI,
You can use following signature to retrieve data not in Android main thread:
Backendless.Persistence.of( testTable.class ).find(
new AsyncCallback<BackendlessCollection<testTable>>()
{
@Override
public void handleResponse( BackendlessCollection<testTable> response )
{
// handle retrieved data
}
@Override
public void handleFault( BackendlessFault fault )
{
// handle exception
}
} );
Regards,
Denys
I use that also still it responds like the same as
BackendlessFault{ code: ‘Internal client exception’, message: ‘Can’t create handler inside thread that has not called Looper.prepare()’ }
void getData() {
Backendless.Persistence.of(testTable.class).find(
new AsyncCallback<BackendlessCollection<testTable>>()
{
@Override
public void handleResponse(BackendlessCollection<testTable> response) {
// handle retrieved data
Log.e("", “” + response.toString());
}
@Override
public void handleFault(BackendlessFault fault) {
// handle exception
Log.e("", "" + fault.toString());
}
});
}
BackendlessFault{ code: ‘Internal client exception’, message: ‘Can’t create handler inside thread that has not called Looper.prepare()’ }
I can access the date from the Users Table by using the BackendlessUsers Object. But i cant able to access the customized objects like Users, testTable like that…
Can you please send example of your code with current issue?
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import com.backendless.Backendless;
import com.backendless.BackendlessCollection;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.exceptions.BackendlessFault;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Backendless.initApp(getApplicationContext(), Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);
Button button = (Button) findViewById(R.id.click);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getData();
}
});
}
void getData() {
Backendless.Persistence.of(testTable.class).find(
new AsyncCallback<BackendlessCollection<testTable>>()
{
@Override
public void handleResponse(BackendlessCollection<testTable> response) {
Log.e("", "" + response.toString());
}
@Override
public void handleFault(BackendlessFault fault) {
Log.e("", "" + fault.toString());
}
});
}
class testTable {
String created;
String ownerId;
String objectId;
String updated;
String Neme;
testTable() {
}
public String getOwnerId() {
return ownerId;
}
public void setOwnerId(String ownerId) {
this.ownerId = ownerId;
}
public String getObjectId() {
return objectId;
}
public void setObjectId(String objectId) {
this.objectId = objectId;
}
public String getUpdated() {
return updated;
}
public void setUpdated(String updated) {
this.updated = updated;
}
public String getNeme() {
return Neme;
}
public void setNeme(String neme) {
Neme = neme;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
}
public class Defaults
{
public static final String APPLICATION_ID = "235E9A18-408D-2B95-FFA9-3A7378AC1C00";
public static final String SECRET_KEY = "10E93804-2C2B-B03D-FFBA-97BA0EA6E000";
public static final String VERSION = "v1";
}
Hi,
I tried with both gradle and jar. Still i am getting " BackendlessFault{ code: ‘Internal client exception’, message: ‘Can’t create handler inside thread that has not called Looper.prepare()’ } "
Kindly do the needful.
Thanks,
Abdullah.S
Hi Abdullah,
We cannot reproduce your issue with this activity.
According to this issue: http://stackoverflow.com/questions/17379002/java-lang-runtimeexception-cant-create-handler-inside-thread-that-has-not-call
the problem can arrise if you try to call UI events in background thread.
If this wouldn’t fix your problem, please send the whole project.
Regards,
Denys
- Move “testTable” class to separate class and make it public
- Define default public no-argument constructor inside it
Thanks Alex . Works fine.