I'm getting this error when trying to retrieve an image from a url using Asynctask. This is my asynctask:

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap result = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            result = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return result;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
        if (result != null && !result.isRecycled()) {
            result.recycle();
            result = null;
        }
    }
}

If I remove the result.recycle(), the error would be OutofMemoryError. I'm retrieving multiple images from different url. How can I do this? I'm calling the asynctask by:

new DownloadImageTask(imageview[i]).execute(paths.get(i));

Many thanks, :)

I'm trying to duotone an image and plaster it onto a canvas.

Works in desktop browsers:

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer

Fails in mobile browsers:

  • iOS Chrome
  • iOS Safari
  • Android

The code is:

<style>
body {
    background-color: gray;
}
</style>

<canvas id="mycanvas" width="64" height="64"></canvas>

<script>
var image = new Image();
image.src = 'image.png';

image.onload = function() {
    var context = document.getElementById("mycanvas").getContext("2d");
    context.drawImage(image, 0, 0);

    var imageData = context.getImageData(0, 0, 64, 64);
    var pixels    = imageData.data;
    var numPixels = pixels.length;

    for (var i = 0; i < numPixels; i++) {
        var index   = i * 4;
        var average = (pixels[index] + pixels[index + 1] + pixels[index + 2]) / 3;

        pixels[index]     = average + 255;
        pixels[index + 1] = average;
        pixels[index + 2] = average;
        //pixels[index + 3] = pixels[index + 3]; no changes to alpha
    }

    context.clearRect(0, 0, 64, 64);    
    context.putImageData(imageData, 0, 0);
}
</script>

The summary is:

  • set the background color to gray so alpha can be observed easier
  • create a canvas 64 by 64
  • load a image of a smiley face on a transparent background
  • draw the image onto the canvas
  • get the image's data
  • for every pixel, make the red stronger
  • replace the altered image on the canvas

The smiley face looks like this (block-quoted so you can tell it's transparent):

However, in comparison with my chrome and android browser,

The background of the android drawing is reddish while the chrome drawing is completely transparent.

So...

  • What happened here?
  • How can I change the code so that the android drawing so that it matches with the chrome drawing?

I have a textview with some text. Textview have touch events, so user can rotate, scale and translate text. For translation, rotation and scaling i'm using canvas. Canvas is doing this inside onDraw() function. Now i want to have outer bounds of text when it is scaled or rotated, can anybody help me. Thanks in Advance.

I try this piece of code to translate,rotate and scale text on canvas:

canvas.scale(fScaledFactorForTextview,fScaledFactorForTextview,getTextWidth() / (2.0f *   getLineCount()) + fTranslationX, (getTextSize() * getLineCount()) / 2.0f + fTranslationY);
canvas.rotate(fDegrees, getTextWidth() / (2.0f * getLineCount()) + fTranslationX,    (getTextSize() * getLineCount()) / 2.0f + fTranslationY);
canvas.translate(fTranslationX,fTranslationY);

guys, so I am currently doing a navigation application where I need to display several tabs, one of which show a google map.

I have used FragmentPagerAdapter to set up the multi-pages UI and so far for the 2 remaining fragments which do not implements any other nested fragment, it works just fine.

For the map fragment, I noticed the problem of nested fragment, so I followed this guide: https://code.google.com/p/gmaps-api-issues/issues/detail?id=5064#c1 and put the things accordingly into my MapFragment, however, the Fragment does not show me anything, it is just a blank page (I have some other things in that fragment, not just the google map fragment).

Please see where I made mistake, thank you very much :) If you need any other part of the code please tell me.

Here is the code of the Map Fragment

public class MapFragment extends FragmentControl  implements OnSeekBarChangeListener{
public static MapFragment getInstance() {
        if(MapFragment.instance==null) {
            Log.e(TAG,"Map Fragment is not loaded");
        }
        return MapFragment.instance;
    }
public static MapFragment newInstance(int position, String title){
    MapFragment mapFragment = new MapFragment();
    Bundle args = new Bundle();
    args.putInt("current_page", 1);
    args.putString("page_tile", "Map Information");
    mapFragment.setArguments(args);
    return mapFragment;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mCurrentPage = getArguments().getInt("current_page", 1);
        pageTitle = getArguments().getString("page_title");
        MapFragment.instance=this;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    layout = inflater.inflate(R.layout.map, container, false);
    if (layout==null){
        Log.d(TAG,"layout null");
        return null;
    }
    CheckBox camera = (CheckBox)layout.findViewById(R.id.cameraMove);
    camera.setChecked(MapFragment.moveCamera);
    camera.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            MapFragment.moveCamera = isChecked;
        }
    });;
    mTransparencyBar = (SeekBar)layout.findViewById(R.id.transparencySeekBar);
    mTransparencyBar.setMax(TRANSPARENCY_MAX);
    mTransparencyBar.setProgress(0);
    markerList = new ArrayList<Marker>();
    return layout;
}


@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    super.onActivityCreated(savedInstanceState);
    FragmentManager fm = getChildFragmentManager();
    supportfragment = (SupportMapFragment) fm.findFragmentById(R.id.googlemap);
    if (supportfragment == null) {
        supportfragment = SupportMapFragment.newInstance();
        fm.beginTransaction().replace(R.id.googlemap, supportfragment).commit();
        fm.executePendingTransactions();
    }
}

@Override
public void onResume() {
    super.onResume();
    this.createUiMap();
    mapTimer = new Timer();
    mapTimer.scheduleAtFixedRate(new updateCalculationTask(), 0, 100);
    mapTimer.scheduleAtFixedRate(new updateUITask(), 50, MainActivity.uiUpdateRate);    
}
void createUiMap() {
         if (mMap == null) {
            // Try to obtain the map from the SupportMapFragment.
            mMap = supportfragment.getMap();
            // Check if we were successful in obtaining the map.
            if (mMap != null) {
                setUpMap();
                populateMapStartPointsSpinner(layout);
                setStartPointSpinnerListener(layout);
                this.setUpMarker(this.defaultStartPoint.x, this.defaultStartPoint.y);
                FetchSQL.setDRFixData(this.setLocation(defaultStartPoint));
             }
        }
    }

private void setUpMap() {
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 20));
        mImages.add(BitmapDescriptorFactory.fromResource(R.drawable.i3f2));
        mCurrentEntry = 0;
        LatLngBounds newarkBounds = new LatLngBounds(
                new LatLng(1.291926, 103.775114),       // South west corner
                new LatLng(1.292833, 103.776310));      // North east corner
        mGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
                 .image(mImages.get(mCurrentEntry))
                 .positionFromBounds(newarkBounds));
        mTransparencyBar.setOnSeekBarChangeListener(this);
    }
}

And here is the map.xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >



    <CheckBox
        android:id="@+id/cameraMove"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/cameraMove"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true" />

    <TextView
        android:id="@+id/mapStartPointSpinnerLabel"
        android:layout_marginLeft="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/cameraMove"
        android:layout_toRightOf="@id/cameraMove"
        android:text="@string/mapStartPointSpinnerLabel" />


    <Spinner
        android:id="@+id/mapStartPointSpinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/cameraMove"
        android:layout_toRightOf="@id/mapStartPointSpinnerLabel" />

 <LinearLayout
     android:id="@+id/seekbarmenu"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_below="@id/mapStartPointSpinnerLabel"
     android:orientation="horizontal"
     android:layout_marginTop="15dip">

     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/transparency"
         android:layout_gravity="center_vertical" />
     <SeekBar
      android:id="@+id/transparencySeekBar"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"/>
 </LinearLayout>

  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_below="@id/seekbarmenu"
      android:layout_marginTop="15dip" >

    <fragment
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="5dip"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:id="@+id/googlemap" />
  </LinearLayout>

How it is supposed to look like (inside Eclipse View):

enter image description here

How it is on my phone:

enter image description here

I was using android download manager,then i saw wits buggy so basically i went for a intent service to download a file,and from intent service,im updating progress dialog with a handler.

In the intent service im opeining a inputstream and writing the output file with output stream in the download folder.

all ok right now,but my qus is,how can i offer users the option to cancel the download in the middle? my code in onHandleIntent is the following.

        InputStream input = new BufferedInputStream(url.openStream());
        OutputStream output = new FileOutputStream(footyDirectory.toString()+"/demo.mp4");

        byte data[] = new byte[1024];
        long total = 0;
        int count;
        while ((count = input.read(data)) != -1) {
            total += count;
            // publishing the progress....
            Bundle resultData = new Bundle();
            resultData.putInt("progress" ,(int) (total * 100 / fileLength));
            receiver.send(UPDATE_PROGRESS, resultData);
            output.write(data, 0, count);
        }

        output.flush();
        output.close();
        input.close();

i am sending notification with 2 different method with different parameter 1,2 if we get parameter 1 then if we read notification from notification manger it should redirect to chatActvity and if we receive parameter 2 then it should redirect to Home activity when i read notification notification manger please help me where am doing wrong below is my code :

I am getting Message and all parameter when i Pus from server : i am unable to redirect to Home activity and chat activity

public class GcmIntentService extends IntentService {
    Context context;
    public static final int NOTIFICATION_ID = 1;
    private NotificationManager mNotificationManager;
    NotificationCompat.Builder builder;
    public static final String TAG = "GCM Demo";
    String msg;
    String senderID;
    String recieverID;
    int value = 1;
    int reccvingparamtere;
    String time;

    public GcmIntentService() {
        super("GcmIntentService");
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        // TODO Auto-generated method stub
        Bundle extras = intent.getExtras();
        msg = intent.getStringExtra("message");
        senderID = intent.getStringExtra("sender_id");
        recieverID = intent.getStringExtra("reccvier_id");
        reccvingparamtere = intent.getIntExtra("reccvingparamtere",
                reccvingparamtere);
        time = intent.getStringExtra("time");
        // test=intent.getStringExtra("_test");
        SharedPreferences prefs = GcmIntentService.this.getSharedPreferences(
                AppConstants.LOGIN_PREFS, Context.MODE_PRIVATE);
        Chat chat = new Chat();
        chat.setMessage(msg);
        chat.setSenderID(senderID);
        chat.setRecieverID(prefs.getString(AppConstants.MEMBER_ID, ""));
        chat.setSenderName("");
        chat.setRecieverName("");
        DBHelper dbHelper = new DBHelper(GcmIntentService.this);
        dbHelper.addMessage(chat);
        AppConstants.RECEIVED_MSG = msg;
        AppConstants.RECEIVED_RCVID = senderID;
        AppConstants.RECEIVED_SENDID = recieverID;
        AppConstants.RECEIVED_TIME = new Date().toString();
        GcmIntentService.this.sendBroadcast(intent);
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        String messageType = gcm.getMessageType(intent);
        if (!extras.isEmpty()) {

            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
                    .equals(messageType)) {

                if (reccvingparamtere == 1) {

                    sendNotification("Send error: " + extras.toString(),
                            senderID);
                } else if (reccvingparamtere == 2) {
                    sendNotification2("Send error: " + extras.toString(),
                            senderID);
                }
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
                    .equals(messageType)) {
                sendNotification(
                        "Deleted messages on server: " + extras.toString(),
                        senderID);
                // If it's a regular GCM message, do some work.
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
                    .equals(messageType)) {
                // This loop represents the service doing some work.
                for (int i = 0; i < 5; i++) {
                    Log.i(TAG,
                            "Working... " + (i + 1) + "/5 @ "
                                    + SystemClock.elapsedRealtime());
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                    }
                }
                Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
                // Post notification of received message.
                // sendNotification("Received: " + extras.toString());
                if (LociiApplication.FID.equals(senderID))
                    System.out.println("Dont show notifications!");
                else
                    sendNotification(msg, senderID);
                Log.i(TAG, "Received: " + extras.toString());
            }
        }
        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }

    private void sendNotification(String msg, String sender_id) {
        mNotificationManager = (NotificationManager) this
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Intent myintent = new Intent(this, ChatActivity.class);
        myintent.putExtra("message", msg);
        myintent.putExtra("to_id", sender_id);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                myintent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.lokii_notification_icon)
                .setContentTitle("Locii Messge").setAutoCancel(true)
                // .setSound(Uri.parse("android.resource://package_name/raw/sound"))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
                .setContentText(msg);

        mBuilder.setContentIntent(contentIntent);

        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

    private void sendNotification2(String msg, String sender_id) {
        mNotificationManager = (NotificationManager) this
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Intent myintent = new Intent(this, HomeActivity.class);
        myintent.putExtra("message", msg);
        myintent.putExtra("to_id", sender_id);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                myintent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.lokii_notification_icon)
                .setContentTitle("Locii Messge").setAutoCancel(true)
                // .setSound(Uri.parse("android.resource://package_name/raw/sound"))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
                .setContentText(msg);

        mBuilder.setContentIntent(contentIntent);

        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

}

I am facing the below issue in monkey talk application with Windows.

The "record" button is not working when i tried use monkey talk with the Hybrid app running on android emulator.So i tried to write scripts and run it but it shows the below error.

ERROR: Timeout connecting to localhost:16862/fonemonkey .Read timed out

Please provide me solutions for this issue....

Also, Is it possible to test PhoneGap(Hybrid) applications using MonkeyTalk ??? Or Did i missed any configurations..??

Thanks in advance.

Regards, Shara

java.lang.NullPointerException at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3069) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchDraw(PhoneWindow.java:2387) at android.view.View.getDisplayList(View.java:13580) at android.view.View.getDisplayList(View.java:13635) at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1627) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1506) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2728) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2593)

while searching for this , i found that it only happens when we change layouts/view in onAnimationEnd(). Here is my onAnimationEnd()...

   public void onAnimationEnd(Animation animation) {
                        if(productList != null)
                            productList.bringToFront();
                        if(toggleView != null)
                            toggleView.bringToFront();
                        if(footerView != null)
                            footerView.bringToFront();
                        if(headerView != null) {
                            headerView.setVisibility(View.INVISIBLE);
                            headerView.clearAnimation();
                        }
                    }

I haven't change any view or layout but still getting lot of these errors

I'm currently developing an android app using MVP Pattern.

When I try to develop an Activity, I should use a ListView. So I'm using Adapter for ListView. But I heard Adapter is similar to Presenter on MVP Pattern.

I think if Apdater is smiliar to Presenter, then I should make Presenter for updating ListView instead of Adapter.

When this situation, how to develop ListView? Just use Adapter and keep using MVP Pattern?

Thanks for your reading.

I'm trying to get fullcalendar on a phonegap app. My code is working on a browser but on the android emulador it is just not showing the calendar. I also tried to get it inside 'device ready' but if I do that I get Object [object Object] has no method 'fullCalendar' error.

inside device ready:

var app = {

        initialize: function() {
            this.bindEvents()
        },

        bindEvents: function() {
            document.addEventListener('deviceready', this.onDeviceReady, false)
            $(document).on("pageshow", app.onDeviceReady);
        },

        onDeviceReady: function() {
            app.receivedEvent('deviceready')
        },

        receivedEvent: function(id){

            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();

            $('#calendar').fullCalendar({
                theme: true,
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                editable: true,
                events: [
                    {
                        title: 'All Day Event',
                        start: new Date(y, m, 1)
                    },
                    {
                        title: 'Long Event',
                        start: new Date(y, m, d-5),
                        end: new Date(y, m, d-2)
                    },
                    {
                        id: 999,
                        title: 'Repeating Event',
                        start: new Date(y, m, d-3, 16, 0),
                        allDay: false
                    },
                    {
                        id: 999,
                        title: 'Repeating Event',
                        start: new Date(y, m, d+4, 16, 0),
                        allDay: false
                    },
                    {
                        title: 'Meeting',
                        start: new Date(y, m, d, 10, 30),
                        allDay: false
                    },
                    {
                        title: 'Lunch',
                        start: new Date(y, m, d, 12, 0),
                        end: new Date(y, m, d, 14, 0),
                        allDay: false
                    },
                    {
                        title: 'Birthday Party',
                        start: new Date(y, m, d+1, 19, 0),
                        end: new Date(y, m, d+1, 22, 30),
                        allDay: false
                    },
                    {
                        title: 'Click for Google',
                        start: new Date(y, m, 28),
                        end: new Date(y, m, 29),
                        url: 'http://google.com/'
                    }
                ]
            });
   }

if i put it outside it will run fine on browser.. but not on emulator :/

demo: http://jsfiddle.net/KrZJr/86/

Is it possible to use fullcalendar on android or is it a plugin with the same effect that works on android?

I have an activity Activity1 with 2 fragments. Everything's working fine but I have one issue :

when I quit the current activity -Activity1- (without calling finish ()) and go to another one Activity2, then I click on the backButton on the last activity I go back to the Activity1 and the onResume method is executed and this is the onResume activity code :

fragmentManager.beginTransaction ().replace (
                                            R.id.my_frame_container, 
                                            fragmentFactory.getFragment (Fragment1)
                                        ).commit ();

From the Documentation : the onResume method of the fragment is called when the onResume method of the activity is too.

However in my case the onResume of the Fragment is not called when I get back to the activity.

Do you have any idea how can I execute fragment code when the onResume of the activity is called ? Thank you.

I'm using SwipeRefreshListener from the support libraries. I am calling setRefresh from onPreExecute and onPostExecute of my AsyncTask. However, nothing changes, there is no animation. Is there something that I'm missing? Are there certain setup parameters I need to set in order for it to work properly?

I writing a game for android with libgdx every time i pressed Back key of phone the app completely exit but i want when i press Back key the game pause , How can i handle this ? in fact how can i detect when this key(s) is pressed :

My last try was : Gdx.input.isButtonPressed(Input.Buttons.LEFT) but it didn't work.

Is there any way to detect resource load error events? (e.g. images)
Currently there is the onReceivedError event in the WebViewClient which handles unrecoverable errors. I'm interested mainly in listening to image load error events.

I'm trying to set up a UI similar to facebook/twitter/google+ with notifications to connected users :

Facebook's actionbar

note that my users are connected with facebook, then a parse.com user is created with facebook's informations.

Can you give me a link to a guide or tutorial about setting up this notification system for logged in users ? thank you.

I copied the TextView style "R.layout.simple_list_item_1" from the R object for use out of a list, because I want replicate this text appareance on a normal textview.

But I have getting some errors like this:

?android:attr/listPreferredItemHeightSmall requires API level 14 (current min is 8)

If this its true, the List View with R.layout.simple_list_item_1 have to cause the same error but this doesn't. Any idea?

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:gravity="center_vertical"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>

I tried with this too, this clean xml layout errors but Im getting errors on run the app when inflate the view:

<TextView
    android:id="@+id/title_play"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:minHeight="@attr/listPreferredItemHeightSmall"
    android:paddingEnd="@attr/listPreferredItemPaddingRight"
    android:paddingStart="@attr/listPreferredItemPaddingLeft"
    android:text="@string/title_play"
    android:textAppearance="@attr/textAppearanceListItemSmall"
    />

Firstly Thank you for helping out.I have copied and edited a code for a simple calender in eclipse, it compiles and builds but the application crashes unexpectedly when i run the application in the android emulator

THIS IS THE ERROR MESSAGE IN LOGCAT

07-20 08:50:15.409: E/AndroidRuntime(1210): FATAL EXCEPTION: main
07-20 08:50:15.409: E/AndroidRuntime(1210): Process: com.trial.dateandtime, PID: 1210
07-20 08:50:15.409: E/AndroidRuntime(1210): java.lang.RuntimeException: Unable to
 instantiate activity ComponentInfo{com.trial.dateandtime/com.trial.dateandtime.
MyCalenderActivity}: java.lang.ClassNotFoundException: Didn't find class "com.trial.
dateandtime.MyCalenderActivity" on path: DexPathList[[zip file "/data/app/com.trial.dateand
time-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.trial.dateandtime-2, /system/lib]]
07-20 08:50:15.409: E/AndroidRuntime(1210):     at android.app.ActivityThread
 performLaunchActivity(ActivityThread.java:2121)
07-20 08:50:15.409: E/AndroidRuntime(1210):     at android.app.ActivityThread
.handleLaunchActivity(ActivityThread.java:2245)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at android.app.ActivityThread.
 access$800(ActivityThread.java:135)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1196) 
07-20 08:50:15.409: E/AndroidRuntime(1210):     at android.os.Handler.dispatch
Message(Handler.java:102)
07-20 08:50:15.409: E/AndroidRuntime(1210):     at android.os.Looper.loop

 (Looper.java:136)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at android.app.ActivityThread.
 main(ActivityThread.java:5017)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at java.lang.reflect.Method.invoke
 Native(Native Method)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at java.lang.reflect.Method.invoke
 (Method.java:515)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at com.android.internal.os.
 ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at com.android.internal.os.
 ZygoteInit.main(ZygoteInit.java:595)
 07-20 08:50:15.409: E/AndroidRuntime(1210):    at dalvik.system.NativeStart.main
 (Native Method)
 07-20 08:50:15.409: E/AndroidRuntime(1210): Caused by: java.lang.ClassNotFoundException:
 Didn't find class "com.trial.dateandtime.MyCalenderActivity" on path: DexPathList[[zip file "/data
 /app/com.trial.dateandtime-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.trial.dateandtime-2,
 /system/lib]]
07-20 08:50:15.409: E/AndroidRuntime(1210):     at dalvik.system.BaseDexClassLoader.
findClass(BaseDexClassLoader.java:56)
07-20 08:50:15.409: E/AndroidRuntime(1210):     at java.lang.ClassLoader.loadClass
(ClassLoader.java:497)
07-20 08:50:15.409: E/AndroidRuntime(1210):     at java.lang.ClassLoader.loadClass
(ClassLoader.java:457)
07-20 08:50:15.409: E/AndroidRuntime(1210):     at android.app.Instrumentation.new
Activity(Instrumentation.java:1061)
07-20 08:50:15.409: E/AndroidRuntime(1210):     at android.app.ActivityThread.
performLaunchActivity(ActivityThread.java:2112)
07-20 08:50:15.409: E/AndroidRuntime(1210):     ... 11 more
07-20 08:50:21.139: I/Process(1210): Sending signal. PID: 1210 SIG: 9

The java files and xml files are

MyCalenderActivity.java

package com.trial.dateandtime;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;


import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;


@TargetApi(3)
public class MyCalendarActivity extends Activity implements OnClickListener {
    private static final String tag = "MyCalendarActivity";

    private TextView currentMonth;
    private Button selectedDayMonthYearButton;
    private ImageView prevMonth;
    private ImageView nextMonth;
    private GridView calendarView;
    private GridCellAdapter adapter;
    private Calendar _calendar;
    @SuppressLint("NewApi")
    private int month, year;
    @SuppressLint({ "NewApi", "NewApi", "NewApi", "NewApi" })
    private final DateFormat dateFormatter = new DateFormat();
    private static final String dateTemplate = "MMMM yyyy";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_calender_view);

        _calendar = Calendar.getInstance(Locale.getDefault());
        month = _calendar.get(Calendar.MONTH) + 1;
        year = _calendar.get(Calendar.YEAR);
        Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: "
                + year);

        selectedDayMonthYearButton = (Button) this
                .findViewById(R.id.selectedDayMonthYear);
        selectedDayMonthYearButton.setText("Selected: ");

        prevMonth = (ImageView) this.findViewById(R.id.prevMonth);
        prevMonth.setOnClickListener(this);

        currentMonth = (TextView) this.findViewById(R.id.currentMonth);
        currentMonth.setText(DateFormat.format(dateTemplate,
                _calendar.getTime()));

        nextMonth = (ImageView) this.findViewById(R.id.nextMonth);
        nextMonth.setOnClickListener(this);

        calendarView = (GridView) this.findViewById(R.id.calendar);

        // Initialized
        adapter = new GridCellAdapter(getApplicationContext(),
                R.id.calendar_day_gridcell, month, year);
        adapter.notifyDataSetChanged();
        calendarView.setAdapter(adapter);
    }

    /**
     * 
     * @param month
     * @param year
     */
    private void setGridCellAdapterToDate(int month, int year) {
        adapter = new GridCellAdapter(getApplicationContext(),
                R.id.calendar_day_gridcell, month, year);
        _calendar.set(year, month - 1, _calendar.get(Calendar.DAY_OF_MONTH));
        currentMonth.setText(DateFormat.format(dateTemplate,
                _calendar.getTime()));
        adapter.notifyDataSetChanged();
        calendarView.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {
        if (v == prevMonth) {
            if (month <= 1) {
                month = 12;
                year--;
            } else {
                month--;
            }
            Log.d(tag, "Setting Prev Month in GridCellAdapter: " + "Month: "
                    + month + " Year: " + year);
            setGridCellAdapterToDate(month, year);
        }
        if (v == nextMonth) {
            if (month > 11) {
                month = 1;
                year++;
            } else {
                month++;
            }
            Log.d(tag, "Setting Next Month in GridCellAdapter: " + "Month: "
                    + month + " Year: " + year);
            setGridCellAdapterToDate(month, year);
        }

    }

    @Override
    public void onDestroy() {
        Log.d(tag, "Destroying View ...");
        super.onDestroy();
    }

    // Inner Class
    public class GridCellAdapter extends BaseAdapter implements OnClickListener {
        private static final String tag = "GridCellAdapter";
        private final Context _context;

        private final List<String> list;
        private static final int DAY_OFFSET = 1;
        private final String[] weekdays = new String[] { "Sun", "Mon", "Tue",
                "Wed", "Thu", "Fri", "Sat" };
        private final String[] months = { "January", "February", "March",
                "April", "May", "June", "July", "August", "September",
                "October", "November", "December" };
        private final int[] daysOfMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,
                31, 30, 31 };
        private int daysInMonth;
        private int currentDayOfMonth;
        private int currentWeekDay;
        private Button gridcell;
        private TextView num_events_per_day;
        private final HashMap<String, Integer> eventsPerMonthMap;
        private final SimpleDateFormat dateFormatter = new SimpleDateFormat(
                "dd-MMM-yyyy");

        // Days in Current Month
        public GridCellAdapter(Context context, int textViewResourceId,
                int month, int year) {
            // super();
            this._context = context;
            this.list = new ArrayList<String>();
            Log.d(tag, "==> Passed in Date FOR Month: " + month + " "
                    + "Year: " + year);
            Calendar calendar = Calendar.getInstance();
            setCurrentDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
            setCurrentWeekDay(calendar.get(Calendar.DAY_OF_WEEK));
            Log.d(tag, "New Calendar:= " + calendar.getTime().toString());
            Log.d(tag, "CurrentDayOfWeek :" + getCurrentWeekDay());
            Log.d(tag, "CurrentDayOfMonth :" + getCurrentDayOfMonth());

            // Print Month
            printMonth(month, year);

            // Find Number of Events
            eventsPerMonthMap = findNumberOfEventsPerMonth(year, month);
        }

        private String getMonthAsString(int i) {
            return months[i];
        }

        private String getWeekDayAsString(int i) {
            return weekdays[i];
        }

        private int getNumberOfDaysOfMonth(int i) {
            return daysOfMonth[i];
        }

        public String getItem(int position) {
            return list.get(position);
        }

        @Override
        public int getCount() {
            return list.size();
        }

        /**
         * Prints Month
         * 
         * @param mm
         * @param yy
         */
        private void printMonth(int mm, int yy) {
            Log.d(tag, "==> printMonth: mm: " + mm + " " + "yy: " + yy);
            int trailingSpaces = 0;
            int daysInPrevMonth = 0;
            int prevMonth = 0;
            int prevYear = 0;
            int nextMonth = 0;
            int nextYear = 0;

            int currentMonth = mm - 1;
            String currentMonthName = getMonthAsString(currentMonth);
            daysInMonth = getNumberOfDaysOfMonth(currentMonth);

            Log.d(tag, "Current Month: " + " " + currentMonthName + " having "
                    + daysInMonth + " days.");

            GregorianCalendar cal = new GregorianCalendar(yy, currentMonth, 1);
            Log.d(tag, "Gregorian Calendar:= " + cal.getTime().toString());

            if (currentMonth == 11) {
                prevMonth = currentMonth - 1;
                daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
                nextMonth = 0;
                prevYear = yy;
                nextYear = yy + 1;
                Log.d(tag, "*->PrevYear: " + prevYear + " PrevMonth:"
                        + prevMonth + " NextMonth: " + nextMonth
                        + " NextYear: " + nextYear);
            } else if (currentMonth == 0) {
                prevMonth = 11;
                prevYear = yy - 1;
                nextYear = yy;
                daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
                nextMonth = 1;
                Log.d(tag, "**--> PrevYear: " + prevYear + " PrevMonth:"
                        + prevMonth + " NextMonth: " + nextMonth
                        + " NextYear: " + nextYear);
            } else {
                prevMonth = currentMonth - 1;
                nextMonth = currentMonth + 1;
                nextYear = yy;
                prevYear = yy;
                daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
                Log.d(tag, "***---> PrevYear: " + prevYear + " PrevMonth:"
                        + prevMonth + " NextMonth: " + nextMonth
                        + " NextYear: " + nextYear);
            }

            int currentWeekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
            trailingSpaces = currentWeekDay;

            Log.d(tag, "Week Day:" + currentWeekDay + " is "
                    + getWeekDayAsString(currentWeekDay));
            Log.d(tag, "No. Trailing space to Add: " + trailingSpaces);
            Log.d(tag, "No. of Days in Previous Month: " + daysInPrevMonth);

            if (cal.isLeapYear(cal.get(Calendar.YEAR)))
                if (mm == 2)
                    ++daysInMonth;
                else if (mm == 3)
                    ++daysInPrevMonth;

            // Trailing Month days
            for (int i = 0; i < trailingSpaces; i++) {
                Log.d(tag,
                        "PREV MONTH:= "
                                + prevMonth
                                + " => "
                                + getMonthAsString(prevMonth)
                                + " "
                                + String.valueOf((daysInPrevMonth
                                        - trailingSpaces + DAY_OFFSET)
                                        + i));
                list.add(String
                        .valueOf((daysInPrevMonth - trailingSpaces + DAY_OFFSET)
                                + i)
                        + "-GREY"
                        + "-"
                        + getMonthAsString(prevMonth)
                        + "-"
                        + prevYear);
            }

            // Current Month Days
            for (int i = 1; i <= daysInMonth; i++) {
                Log.d(currentMonthName, String.valueOf(i) + " "
                        + getMonthAsString(currentMonth) + " " + yy);
                if (i == getCurrentDayOfMonth()) {
                    list.add(String.valueOf(i) + "-BLUE" + "-"
                            + getMonthAsString(currentMonth) + "-" + yy);
                } else {
                    list.add(String.valueOf(i) + "-WHITE" + "-"
                            + getMonthAsString(currentMonth) + "-" + yy);
                }
            }

            // Leading Month days
            for (int i = 0; i < list.size() % 7; i++) {
                Log.d(tag, "NEXT MONTH:= " + getMonthAsString(nextMonth));
                list.add(String.valueOf(i + 1) + "-GREY" + "-"
                        + getMonthAsString(nextMonth) + "-" + nextYear);
            }
        }

        /**
         * NOTE: YOU NEED TO IMPLEMENT THIS PART Given the YEAR, MONTH, retrieve
         * ALL entries from a SQLite database for that month. Iterate over the
         * List of All entries, and get the dateCreated, which is converted into
         * day.
         * 
         * @param year
         * @param month
         * @return
         */
        private HashMap<String, Integer> findNumberOfEventsPerMonth(int year,
                int month) {
            HashMap<String, Integer> map = new HashMap<String, Integer>();

            return map;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = convertView;
            if (row == null) {
                LayoutInflater inflater = (LayoutInflater) _context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = inflater.inflate(R.layout.screen_gridcell, parent, false);
            }

            // Get a reference to the Day gridcell
            gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);
            gridcell.setOnClickListener(this);

            // ACCOUNT FOR SPACING

            Log.d(tag, "Current Day: " + getCurrentDayOfMonth());
            String[] day_color = list.get(position).split("-");
            String theday = day_color[0];
            String themonth = day_color[2];
            String theyear = day_color[3];
            if ((!eventsPerMonthMap.isEmpty()) && (eventsPerMonthMap != null)) {
                if (eventsPerMonthMap.containsKey(theday)) {
                    num_events_per_day = (TextView) row
                            .findViewById(R.id.num_events_per_day);
                    Integer numEvents = (Integer) eventsPerMonthMap.get(theday);
                    num_events_per_day.setText(numEvents.toString());
                }
            }

            // Set the Day GridCell
            gridcell.setText(theday);
            gridcell.setTag(theday + "-" + themonth + "-" + theyear);
            Log.d(tag, "Setting GridCell " + theday + "-" + themonth + "-"
                    + theyear);

            if (day_color[1].equals("GREY")) {
                gridcell.setTextColor(getResources()
                        .getColor(R.color.lightgray));
            }
            if (day_color[1].equals("WHITE")) {
                gridcell.setTextColor(getResources().getColor(
                        R.color.lightgray02));
            }
            if (day_color[1].equals("BLUE")) {
                gridcell.setTextColor(getResources().getColor(R.color.orrange));
            }
            return row;
        }

        @Override
        public void onClick(View view) {
            String date_month_year = (String) view.getTag();
            selectedDayMonthYearButton.setText("Selected: " + date_month_year);
            Log.e("Selected date", date_month_year);
            try {
                Date parsedDate = dateFormatter.parse(date_month_year);
                Log.d(tag, "Parsed Date: " + parsedDate.toString());

            } catch (ParseException e) {
                e.printStackTrace();
            }
        }

        public int getCurrentDayOfMonth() {
            return currentDayOfMonth;
        }

        private void setCurrentDayOfMonth(int currentDayOfMonth) {
            this.currentDayOfMonth = currentDayOfMonth;
        }

        public void setCurrentWeekDay(int currentWeekDay) {
            this.currentWeekDay = currentWeekDay;
        }

        public int getCurrentWeekDay() {
            return currentWeekDay;
        }
    }
}

my_calender_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/lightgray"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/buttonlayout"
        android:layout_width="fill_parent"
        android:layout_height="60sp"
        android:background="@drawable/topbar"
        android:gravity="left|top"
        android:height="60sp"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/settings"
            android:layout_width="54sp"
            android:layout_height="60sp"
            android:background="@drawable/meenu" />

        <ImageView
            android:id="@+id/prevMonth"
            android:layout_width="20sp"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_marginLeft="10sp"
            android:src="@drawable/calendar_left_arrow_selector" >
        </ImageView>

        <TextView
            android:id="@+id/currentMonth"
            android:layout_width="fill_parent"
            android:layout_height="60sp"
            android:layout_weight="0.6"
            android:gravity="center"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#FFFFFF" >
        </TextView>

        <ImageView
            android:id="@+id/nextMonth"
            android:layout_width="20sp"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_marginRight="10sp"
            android:src="@drawable/calendar_right_arrow_selector" >
        </ImageView>

        <Button
            android:id="@+id/addEvent"
            android:layout_width="54sp"
            android:layout_height="60sp"
            android:background="@drawable/plus" />
    </LinearLayout>

    <Button
        android:id="@+id/selectedDayMonthYear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/calendar_top_header"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FFFFFF" >
    </Button>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center" >

        <ImageView
            android:id="@+id/calendarheader"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/calendar_days" >
        </ImageView>
    </LinearLayout>

    <GridView
        android:id="@+id/calendar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:numColumns="7" >
    </GridView>

</LinearLayout>

screen_gridcell.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/calendar_button_selector"
    android:orientation="vertical" >

    <Button
        android:id="@+id/calendar_day_gridcell"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/calendar_button_selector"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FFFFFF" >
    </Button>


    <TextView
        android:id="@+id/num_events_per_day"
        style="@style/calendar_event_style"
        android:layout_width="10dip"
        android:layout_height="10dip"
        android:layout_gravity="right" >
    </TextView>
</RelativeLayout>

I have searched all over, found a bunch of sites but either they don't load, or they have 1 line of code, or i don't know what.

Does anyone have a link please?

Hi i am Beginner in Android and Java..I am currently building Android quiz game. The application should display 6 questions with 4 answers, if the player's answer is correct then player will move to another question and score 5 points, feedback to the player should be provided as well (im planning to use Toast for this one). In the end, player will get to the final screen to see the total score and correct answer.. Now, I am not sure how to display the 6 Questions and 4 answers by using ArrayList? the questions and answers also should be stored in file (im not planning to use SQLdbhelper)

i am new with quiz/trivia game before.here is what i have done so far:

public class play extends Activity implements OnClickListener {

private int totalcorrectanswers;
private int correctanswers;
private Random random;
private TextView questiontextview;
private int score;
private int finalscore;


Button answer1,answer2,answer3,answer4;
Button AnswerButtons [] = {answer1,answer2,answer3,answer4};



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

        View AnswerButton1 = findViewById(R.id.answerbutton1);
        AnswerButton1.setOnClickListener(this);
        View AnswerButton2 = findViewById(R.id.answerbutton2);
        AnswerButton2.setOnClickListener(this);
        View AnswerButton3 = findViewById(R.id.answerbutton3);
        AnswerButton3.setOnClickListener(this);
        View AnswerButton4 = findViewById(R.id.answerbutton4);
        AnswerButton4.setOnClickListener(this);



    }

I am developing iOS and android application. I want to prevent the user from logging in into the app from the different devices which may have different sim card into the devices.

For Example, If user has device A and he logged in into the app, then he cannot get log in into the app from other devices called as device B which has different sim card. Also, please note that if the user has a same mobile number on different devices, then he is an authorize user and can log in into the app.

So, Can i put restriction based on user's sim card details? or else what can i do to prevent the users from getting an unauthorized log in into the app?

Any help will be appreciated. Thanks in advance.

Issue:

I have a FragmentActivity called HomeFragment which has a Drawer with a ListView thats items take the user to other Fragments and Activities. When I click on an item that's supposed to take me to another Fragment, it works perfectly... but if I click on the one item (case MY_LOANS) that's supposed to take me to a different Activity, the application crashes with a NullPointerException in onSaveInstanceState.

I didn't know which part of my HomeActivity to specifically include because I'm not sure where the error is. However, the most relevant part I think is displayView() under the MY_LOANS case statement, where I call startActivity(). onSaveInstanceState() is also relevant because I get the null pointer there. The exact logcat error is below the code.

Another observation:

The app only crashes (with the whole Unfortunately... dialog) AFTER navigating to the MyLoans activity, which is weird I think.

Possible Duplicate? :

I should mention that the problem I have seems to be EXACTLY the same as in this SO question. However, the solution mentioned in the accepted answer does not work for me because my support libraries are up to date.

Also, the nullpointer in my question is on fragment, and NOT on the Bundle.

Code:

@SuppressLint("NewApi")
public class HomeActivity extends FragmentActivity {

public final static String FRAGMENT_TAG = "HomeActivity Fragment";

public final static int 
HOME = 0,
MY_LOANS = 1,
PENDING_REQ = 2,
BUSINESS_PROFILE = 3,
OWNERSHIP = 4,
PROFILE = 5,
NOTIF = 6,
LOGOUT = 7;

private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
private CharSequence mTitle;

// slide menu objects
private String[] mNavMenuTitles;
private TypedArray mNavMenuIcons;
private ArrayList<NavDrawerItem> mNavDrawerItems;
private NavDrawerListAdapter mAdapter;

//To manage user session
private SessionManager mManager;

//To manage fragments
private FragmentManager mFragManager;

private Fragment fragment;

private class SlideMenuClickListener implements ListView.OnItemClickListener {

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        displayView(position, ScreenTransition.FADE);
    }
}

@Override
protected void onCreate(Bundle savedInstanceState) {

    ColorDrawable colorDrawable = new ColorDrawable( Color.TRANSPARENT );
    getWindow().setBackgroundDrawable( colorDrawable );

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    mTitle = getTitle();
    mFragManager = getFragmentManager();

    mNavMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.list_slidermenu);

    mNavDrawerItems = new ArrayList<NavDrawerItem>();
    mNavMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);

    //Add Nav drawer items to array list
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[0], mNavMenuIcons.getResourceId(0, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[1], mNavMenuIcons.getResourceId(1, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[2], mNavMenuIcons.getResourceId(2, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[3], mNavMenuIcons.getResourceId(3, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[4], mNavMenuIcons.getResourceId(4, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[5], mNavMenuIcons.getResourceId(5, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[6], mNavMenuIcons.getResourceId(6, -1)));
    mNavDrawerItems.add(new NavDrawerItem(mNavMenuTitles[7], mNavMenuIcons.getResourceId(7, -1)));

    mNavMenuIcons.recycle();
    mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
    mAdapter = new NavDrawerListAdapter(getApplicationContext(), mNavDrawerItems);
    mDrawerList.setAdapter(mAdapter);

    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle
            (this, mDrawerLayout, R.drawable.ic_drawer, R.string.app_name,  R.string.app_name )
    {
        public void onDrawerClosed(View view) {
            // calling onPrepareOptionsMenu() to show action bar icons
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            // calling onPrepareOptionsMenu() to hide action bar icons
            invalidateOptionsMenu();
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null)
        displayView(0,ScreenTransition.NONE);

}

@Override
public void setTitle(CharSequence title) {
    mTitle = title;
    getActionBar().setTitle(mTitle);
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    // Sync the toggle state after onRestoreInstanceState has occurred.
    mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {

    super.onConfigurationChanged(newConfig);
    // Pass any configuration change to the drawer toggles
    mDrawerToggle.onConfigurationChanged(newConfig);

}

// ******************   PARTICULARLY RELEVANT PART BELOW ******************

@Override
public void onSaveInstanceState(Bundle outState){
    super.onSaveInstanceState(outState);
    mFragManager.putFragment(outState,FRAGMENT_TAG,fragment);
}
@Override
public void onRestoreInstanceState(Bundle inState) {
    super.onRestoreInstanceState(inState);
    fragment = mFragManager.getFragment(inState,FRAGMENT_TAG);
}

public void displayView(int position, ScreenTransition transition) {

    fragment = null;

    switch (position) {

    case HOME:
        fragment = new HomeFragment();
        break;

    case MY_LOANS:

        startActivity(new Intent(HomeActivity.this,MyLoansActivity.class));
        break;

    case PENDING_REQ:
        fragment = new FragmentOne();
        break;

    case BUSINESS_PROFILE:
        fragment = new FragmentTwo();
        break;

    case OWNERSHIP:
        fragment = new FragmentThree();
        break;

    case PROFILE:
        fragment = new FragmentFour();
        break;

    case NOTIF:
        fragment = new FragmentFive();
        break;

    case LOGOUT:
        mManager.logoutUser();
        break;

    }

    if (fragment != null) {

        //Replace fragment
        FragmentTransaction ft = mFragManager.beginTransaction();
        ft.replace(R.id.home_container, fragment, FRAGMENT_TAG);
        ft.addToBackStack(null).commit();

        mDrawerList.setItemChecked(position, true);
        mDrawerList.setSelection(position);
        setTitle(mNavMenuTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);


    }
}

}

Here's my logcat:

07-20 09:47:30.404: E/AndroidRuntime(1122): FATAL EXCEPTION: main
07-20 09:47:30.404: E/AndroidRuntime(1122): Process: com.opendoors.auth, PID: 1122
07-20 09:47:30.404: E/AndroidRuntime(1122): java.lang.NullPointerException
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.FragmentManagerImpl.putFragment(FragmentManager.java:563)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at com.opendoors.core.HomeActivity.onSaveInstanceState(HomeActivity.java:212)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.Activity.performSaveInstanceState(Activity.java:1153)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1223)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3175)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3234)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.ActivityThread.access$1100(ActivityThread.java:135)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.os.Looper.loop(Looper.java:136)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at android.app.ActivityThread.main(ActivityThread.java:5017)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at java.lang.reflect.Method.invokeNative(Native Method)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at java.lang.reflect.Method.invoke(Method.java:515)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-20 09:47:30.404: E/AndroidRuntime(1122):     at dalvik.system.NativeStart.main(Native Method)