Tuesday, January 25, 2011

Android:R can not resolved.

Hi guys,
If you are facing this problem, it means there is some problem in the gen folder in your project. So the best solution to remove this error is to Clean build your project. So just go to Project -> Clean. It will clean the project and now build the project. If it doesn’t work then its better you delete gen folder and do the above steps again.
And Still if it doesn’t work I will suggest you to take back-up of your project and create a new project and now copy the content from old folder to new one. It will work.

Thursday, December 16, 2010

Window fluctuation in case of AlertDialog

Hi Guys,
Today I was facing following problem
Problem:
In Gallery,if you view any image and in that if you select Menu-> Details.
At the time of display image it shows annunciator bar for a moment and just disappear. I dont want this. After analyzing this I found that this is not visible when the items in the dialog is limited to 2-3 items. So suggest me the solution. It is in the Google Froyo code.
So here is the solution for it
Solution:
 AlertDialog alert = builder.create();
Window dwindow = alert.getWindow(); 

dwindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   WindowManager.LayoutParams.FLAG_FULLSCREEN);
alert.show();
Hope this will be useful for you.

Tuesday, December 14, 2010

Android : Pop-up Disappear when configuration changed

If you are facing this problem in your android application, then here is the solution
1. Override onConfigurationChanged() method in your activity.
2. And also add android:configChanges=”orientation|keyboardHidden” in the activity, in AndroidManifest file of that application.
And thats it. Your problem will be resolved.

Thursday, September 2, 2010

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Hi guys,
if you are facing this problem then it is problem with your context which you are passing in the AlertDialog, so make sure you are passing the Context which is initialized by
Context context = this;

And some times in case of Service, you can face this problem while you are using the correct Context. In that case use the following code before show() method.

AlertDialog ad;
// code for creating. .create();
ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
ad.show();

It will work.

Monday, June 14, 2010

noclassdefFounderror map view google maps android

Hi,
If you are facing the  NoClassDefFound Error while using Maps, it means you are not using the Google Api. I mean to say is you need to use Google API in Target in place of Android x.x (version). And also dont forget to include maps.jar. And three modification in xml files.
1. you need to include the Map Key in the main.xml (layout file).
2. you need to add in application attribute in Manifest file.
3. finally you need to give uses-permission to access internet. So add the following line.

Thursday, May 20, 2010

Android : startActivityForResult() Example

Hi,
Here is the code for startActivityForResult() method, I think it will help you to understand this method’s utility
to return the value from called Activity to calling activity.
Calling Activity
 package com.example.checkforresult;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class CheckStartActivityForResult extends Activity {
int requestCode;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d("CheckStartActivity","OnCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent(this,CalledActivity.class);
startActivityForResult(i, requestCode);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("CheckStartActivity","onActivityResult and resultCode = "+resultCode);
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==1){
Toast.makeText(this, "Pass", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(this, "Fail", Toast.LENGTH_LONG).show();
}
}
}
Called Activity
package com.example.checkforresult;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class CalledActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
        Log.d("CalledActivity","OnCreate ");
       //String value = "rahul";
        Intent in = new Intent();
        setResult(1,in);//Here I am Setting the Requestcode 1, you can put according to your requirement
        finish();
}

And Please both services in your manifest file.