samedi 21 mars 2015

Android - Bundle.putString("anything") fails to add string

i am working on Android project in Android Studio 1.1.0 and i can't pass the message to the handler with Bundle class.


Well, this is my code



...
Bundle mUIMessageBundle = new Bundle(newUser.getName());
mUIMessageBundle.putInt("Name", newUser.getName());
mUIMessageBundle.putString("Tag", null);
handler.sendMessage(new android.os.Message());
...


The newUser is well defined but i have a problem on putInt and putString methods. Those methods execute well, but when i read the message in handler getInt and getString return null. So i debugged a bit and the attached pic will show you the problem. Value-key pairs are added, but on their value places are exceptions like this:



java.lang.ClassNotFoundException: Didn't find class "Object" on path: DexPathList[[zip file "/data/app/com.example.mile.voicenc-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.mile.voicenc-1, /vendor/lib, /system/lib]]


I have researched a lot, but i cannot find the solution...


All suggestions will be great, thanks!


Edit 1:


Finally i tried to open whole new blank project and i added two lines for intent init:



...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Intent intent = new Intent("make.your.own.intent");
intent.putExtra("Name", "asd");
}
...


And this code in blank project returned exactly the same exception. It makes me go insane...


Any ideas? Thanks


Aucun commentaire:

Enregistrer un commentaire