Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

In this page you can find the example usage for android.content Intent getStringExtra.

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.amaze.filemanager.services.ExtractService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    b.putInt("id", startId);
    epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", "");
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String file = intent.getStringExtra("zip");
    eentries = intent.getBooleanExtra("entries1", false);
    if (eentries) {
        entries = intent.getStringArrayListExtra("entries");
    }//www  . j ava 2 s  . c  o  m
    b.putString("file", file);
    DataPackage intent1 = new DataPackage();
    intent1.setName(file);
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(cd);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.extracting))
            .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed);
    hash.put(startId, true);
    new Doback().execute(b);
    return START_STICKY;
}

From source file:com.brobwind.brodm.DeviceActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.device);//  w w  w.  j  a v a  2  s .c  om

    startService(new Intent(this, NetworkService.class));
    mKit = new Kit();

    Intent intent = getIntent();
    mIpAddr = intent.getStringExtra(STR_IP);
    mPort = intent.getIntExtra(STR_PORT, -1);

    SharedPreferences.Editor editor = getSharedPreferences(STR_PREF, MODE_PRIVATE).edit();
    editor.putString(STR_IP, mIpAddr);
    editor.putInt(STR_PORT, mPort);
    editor.commit();

    TextView statusTv = (TextView) findViewById(R.id.status);
    statusTv.setText(mIpAddr + ":" + mPort);

    // /privet/info
    mTryInfo = (Button) findViewById(R.id.try_info);
    mTryInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.deviceInfo(mIpAddr, mPort, new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mInfo, msg, error))
                        return;

                    int securePort = -1;
                    try {
                        JSONObject target = new JSONObject(msg);
                        JSONObject endpoints = target.getJSONObject("endpoints");
                        securePort = endpoints.getInt("httpsPort");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    mNetService.init(mIpAddr, mPort, securePort, new NetworkUtils.Callback() {
                        @Override
                        public void onCertAvailable(X509Certificate chains[], String authType) {
                            final StringBuilder sb = new StringBuilder();
                            for (X509Certificate chain : chains) {
                                sb.append(chain.toString());
                            }
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mCert.setText(sb.toString());
                                }
                            });
                        }
                    });

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            enableFuncs(mFuncInfo, null /*mFuncPairing*/);
                            mInfo.setText(msg);
                        }
                    });
                }
            });
        }
    });
    mInfo = (TextView) findViewById(R.id.info);

    // CERT: /privet/info
    mTryCert = (Button) findViewById(R.id.try_cert);
    mTryCert.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.fetchCert("/privet/info", new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    Toast.makeText(DeviceActivity.this, "Web server certificate fetched!", Toast.LENGTH_SHORT)
                            .show();
                }
            });
        }
    });
    mCert = (TextView) findViewById(R.id.cert);

    // /privet/v3/pairing/start
    mTryPairingStart = (Button) findViewById(R.id.try_pairing_start);
    mTryPairingStart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.pairingStart("/privet/v3/pairing/start", new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mPairingStart, msg, error))
                        return;

                    try {
                        JSONObject target = new JSONObject(msg);
                        String id = target.getString("sessionId");
                        String devCmt = target.getString("deviceCommitment");

                        mKit.create("hello", id, devCmt);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            //                        enableFuncs(mFuncPairing, new Button[] { mTryAuth} );
                            mPairingStart.setText(msg);
                        }
                    });
                }
            });
        }
    });
    mPairingStart = (TextView) findViewById(R.id.pairing_start);

    // /privet/v3/pairing/confirm
    mTryPairingConfirm = (Button) findViewById(R.id.try_pairing_confirm);
    mTryPairingConfirm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.pairingConfirm("/privet/v3/pairing/confirm", mKit.getId(), mKit.getCliCmt(),
                    new NetworkUtils.OnMessage() {
                        @Override
                        public void onMessage(final String msg, String error) {
                            if (notifyError(mPairingConfirm, msg, error))
                                return;

                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    //                        enableFuncs(new Button[] { mTryAuth }, null);
                                    mPairingConfirm.setText(msg);
                                }
                            });
                        }
                    });
        }
    });
    mPairingConfirm = (TextView) findViewById(R.id.pairing_confirm);

    // /privet/v3/pairing/cancel
    mTryPairingCancel = (Button) findViewById(R.id.try_pairing_cancel);
    mTryPairingCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.pairingCancel("/privet/v3/pairing/cancel", mKit.getId(), new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mPairingStart, msg, error))
                        return;

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mPairingCancel.setText(msg);
                        }
                    });
                }
            });
        }
    });
    mPairingCancel = (TextView) findViewById(R.id.pairing_cancel);

    // /privet/v3/auth
    mTryAuth = (Button) findViewById(R.id.try_auth);
    mTryAuth.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.startAuth("/privet/v3/auth", mKit.getId(), mKit.getAuthCode(),
                    new NetworkUtils.OnMessage() {
                        @Override
                        public void onMessage(final String msg, String error) {
                            if (notifyError(mPairingStart, msg, error))
                                return;

                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mAuth.setText(msg);
                                }
                            });

                            try {
                                JSONObject target = new JSONObject(msg);
                                mAccessToken = target.getString("accessToken");
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    });
        }
    });
    mAuth = (TextView) findViewById(R.id.auth);

    // /privet/v3/traits
    mTryTraits = (Button) findViewById(R.id.try_traits);
    mTryTraits.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.showTraits("/privet/v3/traits", mAccessToken, new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mTraits, msg, error))
                        return;

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mTraits.setText(msg);
                        }
                    });
                }
            });
        }
    });
    mTraits = (TextView) findViewById(R.id.traits);

    // /privet/v3/components
    mTryComponents = (Button) findViewById(R.id.try_components);
    mTryComponents.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNetService.showComponents("/privet/v3/components", mAccessToken, new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mComponents, msg, error))
                        return;

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mComponents.setText(msg);
                        }
                    });
                }
            });
        }
    });
    mComponents = (TextView) findViewById(R.id.components);

    // /privet/v3/state
    mTryState = (Button) findViewById(R.id.try_state);
    mTryState.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String cmd = "{}";
            mNetService.showCommand("/privet/v3/state", mAccessToken, cmd, new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mCmdInfo, msg, error))
                        return;

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mCmdInfo.setText(msg);
                        }
                    });
                }
            });
        }
    });
    // /privet/v3/commandDefs
    mTryCmdDefs = (Button) findViewById(R.id.try_cmd_defs);
    mTryCmdDefs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String cmd = "{}";
            mNetService.showCommand("/privet/v3/commandDefs", mAccessToken, cmd, new NetworkUtils.OnMessage() {
                @Override
                public void onMessage(final String msg, String error) {
                    if (notifyError(mCmdInfo, msg, error))
                        return;

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mCmdInfo.setText(msg);
                        }
                    });
                }
            });
        }
    });
    // /privet/v3/command/status
    mTryCmdStatus = (Button) findViewById(R.id.try_cmd_status);
    mTryCmdStatus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String cmd = "{}";
            mNetService.showCommand("/privet/v3/commands/status", mAccessToken, cmd,
                    new NetworkUtils.OnMessage() {
                        @Override
                        public void onMessage(final String msg, String error) {
                            if (notifyError(mCmdInfo, msg, error))
                                return;

                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mCmdInfo.setText(msg);
                                }
                            });
                        }
                    });
        }
    });
    // /privet/v3/command/list
    mTryCmdList = (Button) findViewById(R.id.try_cmd_list);
    mTryCmdList.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String cmd = "{}";
            mNetService.showCommand("/privet/v3/commands/list", mAccessToken, cmd,
                    new NetworkUtils.OnMessage() {
                        @Override
                        public void onMessage(final String msg, String error) {
                            if (notifyError(mCmdInfo, msg, error))
                                return;

                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mCmdInfo.setText(msg);
                                }
                            });
                        }
                    });
        }
    });
    mCmdInfo = (TextView) findViewById(R.id.cmd_info);

    // /privet/v3/command/exectue
    mTryCmdExec = (Button) findViewById(R.id.try_cmd_exec);
    mTryCmdExec.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String cmd = ((CharSequence) mCmd.getText()).toString();
            mNetService.showCommand("/privet/v3/commands/execute", mAccessToken, cmd,
                    new NetworkUtils.OnMessage() {
                        @Override
                        public void onMessage(final String msg, String error) {
                            if (notifyError(mCmdExec, msg, error))
                                return;

                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mCmdExec.setText(msg);
                                }
                            });
                        }
                    });
        }
    });
    mCmd = (EditText) findViewById(R.id.cmd);
    mCmd.setText(/*
                 "{\n" +
                 "   \"component\": \"_ledflasher\",\n" +
                 "   \"name\": \"_ledflasher.set\",\n" +
                 "   \"parameters\": {\n" +
                 "      \"led\": 2,\n" +
                 "      \"on\": true\n" +
                 "   }\n" +
                 "}" */
            "{\n" + "   \"name\": \"_ledflasher.animate\",\n" + "   \"parameters\": {\n"
                    + "      \"duration\": 0.2,\n" + "      \"type\": \"marquee_left\"\n" + "   }\n" + "}");
    mCmdExec = (TextView) findViewById(R.id.cmd_exec);

    mFuncAll = new Button[] { mTryInfo, mTryCert, mTryPairingStart, mTryPairingConfirm, mTryPairingCancel,
            mTryAuth, mTryTraits, mTryComponents, mTryState, mTryCmdDefs, mTryCmdStatus, mTryCmdList,
            mTryCmdExec, };
    mFuncInfo = new Button[] { mTryCert, mTryPairingStart, mTryPairingConfirm, mTryPairingCancel, mTryAuth,
            mTryTraits, mTryComponents, mTryState, mTryCmdDefs, mTryCmdStatus, mTryCmdList, mTryCmdExec, };
    mFuncPairing = new Button[] { mTryPairingConfirm, mTryPairingCancel, mTryAuth };
}

From source file:net.evecom.androidecssp.activity.event.ContinueAddActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    // /*  www. ja  v  a 2 s .c  o m*/
    case R.layout.tree_list_at:

        String id = data.getStringExtra("nodeid");
        String name = data.getStringExtra("nodeName");
        String title = data.getStringExtra("title");
        if (null != id) {
            if (title.equals("")) {
                hashMap.put("infoContinue.reporterdept", id);
                hashMap.put("infoContinue.reporterdeptname", name);
                continueDept.setText(name);
            } else {
                hashMap.put("infoContinue.coutinuearea", id);
                continueArea.setText(name);
            }
        }
        break;
    // 
    case R.layout.picture_select_at:
        new Thread(new Runnable() {
            @Override
            public void run() {
                filebeans.removeAll(filebeans);
                filebeans = getDb().findAll(FileManageBean.class);
                Message message = new Message();
                message.what = R.layout.picture_select_at;
                pubHandler.sendMessage(message);
            }
        }).start();
        break;
    default:
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:chaitanya.im.searchforreddit.LauncherActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == 1001) {
        //int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        //String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

        if (resultCode == RESULT_OK) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");
                if (sku.equals("donate") || sku.equals("donate2") || sku.equals("donate3")) {
                    SharedPreferences.Editor editor = sharedPref.edit();
                    donate = 1;//w  ww .  jav a 2s. c  o m
                    editor.putInt(getString(R.string.donate_check), donate);
                    editor.commit();
                    invalidateOptionsMenu();
                    showMessageInSnackbar("Thank you for the donation! It is much appreciated :)");
                }
            } catch (JSONException e) {
                Log.d(TAG, "Failed to parse purchase data.");
                showMessageInSnackbar(
                        "Something went wrong with the purchase! Contact us at overloadapps@gmail.com");
                e.printStackTrace();
            }
        } else if (resultCode == RESULT_CANCELED) {
            Log.d(TAG, "Cancelled");
            showMessageInSnackbar("Purchase cancelled. We hope you reconsider :)");
        }
    }
}

From source file:com.layer8apps.CalendarHandler.java

/************
 *  PURPOSE: Handles the primary thread in the service
 *  ARGUMENTS: Intent intent// www. jav a 2 s  .  c om
 *  RETURNS: VOID
 *  AUTHOR: Devin Collins <agent14709@gmail.com>
 *************/
@Override
protected void onHandleIntent(Intent intent) {
    // Get our stored data from the intent
    username = intent.getStringExtra("username");
    password = intent.getStringExtra("password");
    messenger = (Messenger) intent.getExtras().get("handler");
    calID = intent.getIntExtra("calendarID", -1);

    String url = getApplicationContext().getResources().getString(R.string.url);

    // Create variables to be used through the application
    List<String[]> workDays = null;
    ConnectionManager conn = ConnectionManager.newConnection();

    /************
     * Once we verify that we have a valid token, we get the actual schedule
     *************/
    updateStatus("Logging in...");
    String tempToken = conn.getData(url + "/etm/login.jsp");
    if (tempToken != null) {
        loginToken = parseToken(tempToken);
    } else {
        showError("Error connecting to MyTLC, make sure you have a valid network connection");
        return;
    }

    String postResults = null;
    // This creates our login information
    List<NameValuePair> parameters = createParams();
    if (loginToken != null) {
        // Here we send the information to the server and login
        postResults = conn.postData(url + "/etm/login.jsp", parameters);
    } else {
        showError("Error retrieving your login token");
        return;
    }

    if (postResults != null && postResults.toLowerCase().contains("etmmenu.jsp")
            && !postResults.toLowerCase().contains("<font size=\"2\">")) {
        updateStatus("Retrieving schedule...");
        postResults = conn.getData(url + "/etm/time/timesheet/etmTnsMonth.jsp");
    } else {
        String error = parseError(postResults);
        if (error != null) {
            showError(error);
        } else {
            showError("Error logging in, please verify your username and password");
        }
        return;
    }

    // If we successfully got the information, then parse out the schedule to read it properly
    String secToken = null;
    if (postResults != null) {
        updateStatus("Parsing schedule...");
        workDays = parseSchedule(postResults);
        secToken = parseSecureToken(postResults);
        wbat = parseWbat(postResults);
    } else {
        showError("Could not obtain user schedule");
        return;
    }

    if (secToken != null) {
        parameters = createSecondParams(secToken);
        postResults = conn.postData(url + "/etm/time/timesheet/etmTnsMonth.jsp", parameters);
    } else {
        String error = parseError(postResults);
        if (error != null) {
            showError(error);
        } else {
            showError("Error retrieving your security token");
        }
        return;
    }

    List<String[]> secondMonth = null;
    if (postResults != null) {
        secondMonth = parseSchedule(postResults);
    } else {
        showError("Could not obtain user schedule");
        return;
    }

    if (secondMonth != null) {
        if (workDays == null) {
            workDays = secondMonth;
        } else {
            workDays.addAll(secondMonth);
        }
        finalDays = workDays;
    } else {
        String error = parseError(postResults);
        if (error != null) {
            showError(error);
        } else {
            showError("There was an error retrieving your schedule");
        }
        return;
    }

    // Add our shifts to the calendar
    updateStatus("Adding shifts to calendar...");
    int numShifts = addDays();

    if (finalDays != null && numShifts > -1) {
        // Report back that we're successful!
        Message msg = Message.obtain();
        Bundle b = new Bundle();
        b.putString("status", "DONE");
        b.putInt("count", numShifts);
        msg.setData(b);
        try {
            messenger.send(msg);
        } catch (Exception e) {
            // Nothing
        }
    } else {
        showError("Couldn't add your shifts to your calendar");
    }
}

From source file:my.home.lehome.service.SendMsgIntentService.java

private void preparePengindCommand(Intent intent) {
    Messenger messenger;/*  ww w.  j  a  v  a2 s  .  c  om*/
    if (intent.hasExtra("messenger"))
        messenger = (Messenger) intent.getExtras().get("messenger");
    else
        messenger = null;
    Message repMsg = Message.obtain();
    repMsg.what = MSG_BEGIN_SENDING;

    boolean isSysCmd = intent.getBooleanExtra("isSysCmd", false);
    if (isSysCmd) {
        Log.d(TAG, "sys cmd item");
        return;
    }

    ChatItem item = intent.getParcelableExtra("update");
    if (item == null) {
        item = new ChatItem();
        item.setContent(intent.getStringExtra("cmd"));
        item.setType(ChatItemConstants.TYPE_CLIENT);
        item.setState(Constants.CHATITEM_STATE_ERROR); // set ERROR
        item.setDate(new Date());
        DBStaticManager.addChatItem(getApplicationContext(), item);
    }
    item.setState(Constants.CHATITEM_STATE_PENDING);

    Log.d(TAG, "enqueue item: \n" + item);
    Bundle bundle = new Bundle();
    bundle.putBoolean("update", intent.hasExtra("update"));
    bundle.putParcelable("item", item);
    if (messenger != null) {
        repMsg.setData(bundle);
        try {
            messenger.send(repMsg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_BEGIN);
        Intent newIntent = new Intent(ACTION_SEND_MSG_BEGIN);
        newIntent.putExtras(bundle);
        sendBroadcast(newIntent);
    }

    intent.putExtra("pass_item", item);
}

From source file:com.actionlauncher.api.LiveWallpaperSource.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent == null) {
        return;//from ww w  . j  a  va 2  s.  co  m
    }

    String action = intent.getAction();
    LOGD("LiveWallpaperSource.onHandleIntent() - action:" + action + ", id:" + mName);
    // TODO: permissions?
    if (ACTION_SUBSCRIBE.equals(action)) {
        processSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT),
                intent.getStringExtra(EXTRA_TOKEN));
    } else if (ACTION_FETCH_PALETTE.equals(action)) {
        publishCurrentPalette();
    } else if (action.equals(ProtocolConstants.ACTION_PUBLISH_STATE)) {
        boolean wallpaperInfoSet = false;
        if (intent.hasExtra(EXTRA_LIVE_WALLPAPER_INFO)) {
            Bundle bundle = intent.getExtras().getBundle(EXTRA_LIVE_WALLPAPER_INFO);
            if (bundle != null) {
                LiveWallpaperInfo info = LiveWallpaperInfo.fromBundle(bundle);
                mCurrentState.setCurrentLiveWallpaperInfo(info);
                LOGD("LiveWallpaperInfo.fromBundle():" + (info != null ? info.toString() : null));
                wallpaperInfoSet = true;
            }
        }
        if (!wallpaperInfoSet) {
            mCurrentState.setCurrentLiveWallpaperInfo(null);
        }
        publishCurrentPalette();
    }
}

From source file:com.gimranov.zandy.app.ItemActivity.java

/**
 * Called when the activity is first created.
 *//*  ww  w  . j  a  v a 2  s .co m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String persistedSort = Persistence.read(SORT_CHOICE);
    if (persistedSort != null)
        sortBy = persistedSort;

    db = new Database(this);

    setContentView(R.layout.items);

    Intent intent = getIntent();
    collectionKey = intent.getStringExtra("com.gimranov.zandy.app.collectionKey");

    ItemCollection coll = ItemCollection.load(collectionKey, db);
    APIRequest req;

    if (coll != null) {
        req = APIRequest.fetchItems(coll, false, new ServerCredentials(this));
    } else {
        req = APIRequest.fetchItems(false, new ServerCredentials(this));
    }

    prepareAdapter();

    ItemAdapter adapter = (ItemAdapter) getListAdapter();
    Cursor cur = adapter.getCursor();

    if (intent.getBooleanExtra("com.gimranov.zandy.app.rerequest", false) || cur == null
            || cur.getCount() == 0) {

        if (!ServerCredentials.check(getBaseContext())) {
            Toast.makeText(getBaseContext(), getResources().getString(R.string.sync_log_in_first),
                    Toast.LENGTH_SHORT).show();
            return;
        }

        Toast.makeText(this, getResources().getString(R.string.collection_empty), Toast.LENGTH_SHORT).show();
        Log.d(TAG, "Running a request to populate missing items");
        ZoteroAPITask task = new ZoteroAPITask(this);
        req.setHandler(mEvent);
        task.execute(req);

    }

    ListView lv = getListView();
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // If we have a click on an item, do something...
            ItemAdapter adapter = (ItemAdapter) parent.getAdapter();
            Cursor cur = adapter.getCursor();
            // Place the cursor at the selected item
            if (cur.moveToPosition(position)) {
                // and load an activity for the item
                Item item = Item.load(cur);

                Log.d(TAG, "Loading item data with key: " + item.getKey());
                // We create and issue a specified intent with the necessary data
                Intent i = new Intent(getBaseContext(), ItemDataActivity.class);
                i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey());
                i.putExtra("com.gimranov.zandy.app.itemDbId", item.dbId);
                startActivity(i);
            } else {
                // failed to move cursor-- show a toast
                TextView tvTitle = (TextView) view.findViewById(R.id.item_title);
                Toast.makeText(getApplicationContext(),
                        getResources().getString(R.string.cant_open_item, tvTitle.getText()),
                        Toast.LENGTH_SHORT).show();
            }
        }
    });
}