I am working with an Arduino and trying use two toggle buttons to connect and enable the Arduino. I don't want to be able to press the enable button until I have connected the robot. Here is my main activity:

public class MainActivity extends Activity {

Arduino arduino = null;
ToggleButton enable, connect;

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

    ToggleButton connect = (ToggleButton) findViewById(R.id.buttonConnect);
    ToggleButton enable = (ToggleButton) findViewById(R.id.buttonEnable);

}

public void onToggleClicked(View view) {


    switch(view.getId()) {

        case R.id.buttonConnect:

            boolean on = ((ToggleButton) view).isChecked();

            if(on){

                //Take the text from editText1 and make it the IP Address
                EditText text = (EditText)findViewById(R.id.editText1);
                String ip = text.getText().toString();
                arduino = new Arduino(ip);

                arduino.connect();

                arduino.disable();

            } else {

                arduino.disable();
                arduino.disconnect();
                enable.setChecked(false);
            }
        break;  



        case R.id.buttonEnable:

            boolean click = ((ToggleButton) view).isChecked();

            if(click && connect.isChecked()) {

                arduino.enable();

            }else {

                System.out.println("Not Connected");
                enable.setChecked(False);
                arduino.disable();
            }
        break;  

        default:

        break;  

        }

    }

I know the program is not reaching the else statement in the buttonEnable case because it is not printing out "Not Connected." I have also tried to use connect.isEnabled()in my if statement but that doesn't work either. Does anybody have answer? Thank you!

i have this problem when i try to add my tweet objects to an arraylist in my model, but i'm getting back a NullPointerException. This happens in my SearchTweetsTask class. It only happens when i search for tweets with the twitter api. Getting timelines and stuff works just great, no problems at all. But only when i search for tweets i got this exception. I search for tweets via a searchview in my actionbar which is created in my MainActivity. I hope you can help me.

Here is some code:

    protected String doInBackground(String... params)
    {
        meldingen = "";
        String result = "";
        String searchString = params[0];
        String decoded = "";
        try {
            decoded = URLEncoder.encode(searchString, "UTF-8");
        } catch (UnsupportedEncodingException e1) {
            Log.d("URL ENCODER", "De Search query is niet goed ingelezen");
        }
        String url = "https://api.twitter.com/1.1/search/tweets.json?q=";
        String searchURL = url + decoded + "&count=50";

        try{
            HttpGet get = new HttpGet(searchURL);
            Authenticate.authentication(get);
            ResponseHandler<String> handler = new BasicResponseHandler();
            result = httpClient.execute(get, handler);
            JSONObject json = new JSONObject(result);
            JSONArray jArray = json.getJSONArray("statuses");
            for (int i = 0; i < jArray.length(); i++)
            {
                JSONObject subObject = jArray.getJSONObject(i);
                Tweet tweet = new Tweet (subObject);
                publishProgress(tweet);
            }
        }
        catch(HttpResponseException e)
        {
           //all the catch exceptions
           ....
        }
    //GETTING NULLER POINTER HERE
    protected void onProgressUpdate(Tweet... tweets) {
        for (Tweet tweet : tweets) {
            model.addSearchTweets(tweet);
        }
    }

Model class:

   private ArrayList<Tweet> searchTweets = new ArrayList<Tweet>();

   public void addSearchTweets(Tweet tweet)
   {
       searchTweets.add(tweet);
   }

MainActivity:

   public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actions, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) searchItem.getActionView();

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if(null != searchManager ) 
    {   
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setOnQueryTextListener(new OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String search) {
                model.clearSearchTweets();

                InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);

                Fragment newFragment = new UserSearchTweetsFragment();
                FragmentTransaction transaction = getFragmentManager().beginTransaction();
                transaction.replace(R.id.frame_container, newFragment);
                transaction.addToBackStack(null);

                SearchTweetsTask searchTweets = new SearchTweetsTask(MainActivity.this);
                searchTweets.execute(search);

                transaction.commit();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String search) {
                return true;
            }
        });
    }
    searchView.setIconifiedByDefault(false);
    return true;

07-14 17:18:25.048: E/AndroidRuntime(9135): FATAL EXCEPTION: main 07-14 17:18:25.048: E/AndroidRuntime(9135): Process: nl.timkatgert.tweettweet, PID: 9135 07-14 17:18:25.048: E/AndroidRuntime(9135): java.lang.NullPointerException 07-14 17:18:25.048: E/AndroidRuntime(9135): at nl.timkatgert.tweettweet.tasks.SearchTweetsTask.onProgressUpdate(SearchTweetsTask.java:117) 07-14 17:18:25.048: E/AndroidRuntime(9135): at nl.timkatgert.tweettweet.tasks.SearchTweetsTask.onProgressUpdate(SearchTweetsTask.java:1) 07-14 17:18:25.048: E/AndroidRuntime(9135): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:648) 07-14 17:18:25.048: E/AndroidRuntime(9135): at android.os.Handler.dispatchMessage(Handler.java:102) 07-14 17:18:25.048: E/AndroidRuntime(9135): at android.os.Looper.loop(Looper.java:157) 07-14 17:18:25.048: E/AndroidRuntime(9135): at android.app.ActivityThread.main(ActivityThread.java:5356) 07-14 17:18:25.048: E/AndroidRuntime(9135): at java.lang.reflect.Method.invokeNative(Native Method) 07-14 17:18:25.048: E/AndroidRuntime(9135): at java.lang.reflect.Method.invoke(Method.java:515) 07-14 17:18:25.048: E/AndroidRuntime(9135): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 07-14 17:18:25.048: E/AndroidRuntime(9135): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 07-14 17:18:25.048: E/AndroidRuntime(9135): at dalvik.system.NativeStart.main(Native Method)

I start monitoring GPS_PROVIDER by using the folowing code:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGPS)

When it returns me a location with a good precision (50 meters or less), I plot it into a map and then I stop the locationmanger updates, rescheduling it to start monitoring updates again 2 minutes later.

There are a lot of readings that are perfectly fine, pointing to exact location I am. But sometimes it seems to get 'crazy' and starts to give me wrong locations, but all readings have a good precision (50 meters or less). The strange thing is that my DEVICE IS STILL STANDING sitting on my desktop all the time!

I've tested it with 3 different devices (including tablets and phones) and all of them got same behavior in sometime.

Here's a map showing all locations returned by LocationListener. The green one is the "good one". Red circles show the locations precision (not larger than 50 meters).

Does anybody have any ideia why is it happening?

map

My android app post that includes interactive map and user generated photo. I could not find a way to make both map and photo showed at same post. (Is this possible ? ) What I want to try is to create the post with a interactive map and add a comment with attached photo to achieve previous goal. However is adding comments to existing photo with android app possilble ? If it is could anyone direct me to good examples. ? Thanks !

I am manually adding list items to list view and list item contains one spinner and edit text views. when add new list item to list view all previously entered data refreshing. How can i avoid this issue ?

I am working on an Android based GPS Navigation application and it is necessary to implement automatic day and night theme switcher for the application based on the light sensor values. The problem is I have to change the theme without restarting the Activity or the application.

I tried to achieve this by following this tutorial (http://sriramramani.wordpress.com/2012/12/06/runtime-theme-change/) where custom states are used to change between day and night mode. But it requires lot of changes as my application has many layouts. Also with this implementation developers have to take care of Day and Night modes for future screens.

Is there any simple and effective way to achieve this?

According to the instructions that Building a Simple User Interface on the website of Android Developers, I am goint to open the fragment_main.xml file from the res/layout/ directory. But based on the ADT Bundle 20140702, there is only the activity_main.xml in the res/layout. Or fragment_main.xml can be found on the version 20140321.

I need to write android code with polymer material design code.

Can anyone give me a sample code for polymer material design code for android.

I am new in Android. I'm building an app with sliding bar format and a part of sliding bar is one Fragment. I can convert Activity to Fragment but now I'm have a Fragment Activity and I want to convert it to Fragment. Can I do it in Android. Thanks for your help.

I am working on implementing subscription using Amazon IAP version 2. I am referring to the sample subscription application provided by them, for implementation.

Currently I am testing in Sandbox environment. For this I have set up

  1. Amazon App tester in my device.
  2. placed amazon.sdktester.json file in "mnt/sdcard" directory.

When I make a purchase request, I send child sku in the request as shown in sample. The request status I get in response is SUCCESSFUL. After receipt verification at backend server when I try to grant the subscription purchase, I get INVALID_SKU. When I print the value of SKU, it gives me Parent SKU. And in this case I have to call

PurchasingService.notifyFulfillment(receipt.getReceiptId(),
                    FulfillmentResult.UNAVAILABLE);

Could anyone please explain what exactly is going on her? Why the SKU is invalid?

Scenario:

Start a camera intent where the intent should be able to record or capture image.

What I already know:

  • To start camera intent for recording video

    Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

  • To start camera intent for capturing image

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

Question: I have seen that whenever we start a camera as stand alone we get all the camera options like image capture,video recording,etc.

So,how may I create single intent having both the functionalities programatically ?

Note: I found same question on our forum(Duplicate question) but it was not answered,hence asking it again.

Thanks in advance.

According to the GCM docs, "When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version".

Because Parse SDK handles the device registration part of GCM (as answered here), can anyone tell me if the current Parse SDK (1.5.1) also includes the handling of id invalidating or not?

Thanks in advance!

As the background, I am investigating the reason why my chat application (using Parse + push notification) worked well on some early versions and stop to work (not receive notification) on some latest versions...

The below AlertDialog is not displaying the ICON. I tried the option given in this stackoverflow link.

Alert dialog is not displaying

I tried the below option:

AlertDialog.Builder alertDialog  = new AlertDialog.Builder(TriviaActivity.this);

AlertDialog.Builder alertDialog  = new AlertDialog.Builder(this);

AlertDialog.Builder alertDialog  = new AlertDialog.Buildeer(getApplicationContext()![enter image description here][1]);

Please let me know why the ICON is not displaying.

public void callfacebook()
{
    if ( score > 100 )
    {   mpc.start();    }
    AlertDialog.Builder alertDialog  = new AlertDialog.Builder(TriviaActivity.this);
    alertDialog.setTitle("");
    alertDialog.setIcon(R.drawable.right);
    alertDialog.setMessage("\t Your Score is : " + score + " \n\n Please share this in Facebook");
    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog,int which) {
        Intent activityIntent = new Intent(TriviaActivity.this,facebookcall.class);
           activityIntent.putExtra("messageval","score");
           activityIntent.putExtra("level","level5");
           startActivity(activityIntent);
        }                   
        });
    alertDialog.show();
     }

I have a error when i use the project LiveSDK for Android.Login, upfile, browerfile are normal. But when i download a file, the app has error.

Here's the link ref :enter link description here

Who knows the error?

I have been doing an android database application project recently.When i tried to execute. I cant find the folder 'databases' in the file explorer of the DDMS. I checked the following path /data/data/packagename/databases,but there i could not find databases folder and my database file.

I have attached the code for database helper class please help me if there is any error that is preventing me from creating the database or is it wrong with my eclipse. Because even some of my existing projects also dont show up with the databases folder inside them.

DBclass.java

package pack.andyxdb;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBclass {

public static final String KEY_TIMESTAMP = "Timestamp";
public static final String KEY_UNIQUEID = "UniqueID";
public static final String KEY_DEVICETYPE = "Devicetype";
public static final String KEY_RSSI = "RSSI";

private static final String DATABASE_NAME = "DannyZ.db";
private static final String DATABASE_TABLE = "Data";
private static final int DATABASE_VERSION = 1;

private final Context ourContext;
private DbHelper dbh;
private SQLiteDatabase odb;

private static final String USER_MASTER_CREATE =
    "CREATE TABLE IF NOT EXISTS " + DATABASE_TABLE+ "("
        + KEY_TIMESTAMP + " INTEGER ,"
        + KEY_UNIQUEID  + " INTEGER, " + KEY_DEVICETYPE + " TEXT, " + KEY_RSSI + " INTEGER PRIMARY KEY )";
//CREATE TABLE `DannyZ` (

private static class DbHelper extends SQLiteOpenHelper {

    public DbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(USER_MASTER_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // if DATABASE VERSION changes
        // Drop old tables and call super.onCreate()
    }
}

public DBclass(Context c) {
    ourContext = c;
    dbh = new DbHelper(ourContext);
}

public DBclass open() throws SQLException {
    odb = dbh.getWritableDatabase();
    return this;
}

public void close() {
    dbh.close();
}

public long insertrecord(int timestamp, int uniqueID,String Device, int RSSI) throws SQLException{
   // Log.d("", col1);
   // Log.d("", col2);

    ContentValues IV = new ContentValues();

    IV.put(KEY_TIMESTAMP, timestamp);
    IV.put(KEY_UNIQUEID, uniqueID );
    IV.put(KEY_DEVICETYPE, Device != "");
    IV.put(KEY_RSSI, RSSI );

    return odb.insert(DATABASE_TABLE, null, IV);
    // returns a number >0 if inserting data is successful
}

public void updateRow(long rowID, String col1, String col2,String col3,String col4) {
    ContentValues values = new ContentValues();
    values.put(KEY_TIMESTAMP, col1);
    values.put(KEY_UNIQUEID, col2);
    values.put(KEY_DEVICETYPE, col3);
    values.put(KEY_RSSI, col4);

    try {
        odb.update(DATABASE_TABLE, values, KEY_RSSI + "=" + rowID, null);
    } catch (Exception e) {
    }
}

public boolean delete() {
    return odb.delete(DATABASE_TABLE, null, null) > 0;
}

public Cursor getAllTitles() {
    // using simple SQL query
    return odb.rawQuery("select * from " + DATABASE_TABLE + "ORDER BY "+KEY_RSSI, null);
}

public Cursor getallCols(String id) throws SQLException {
    Cursor mCursor = odb.query(DATABASE_TABLE, new String[] { KEY_TIMESTAMP,
            KEY_UNIQUEID, KEY_DEVICETYPE, KEY_RSSI }, null, null, null, null, null);
    Log.e("getallcols zmv", "opening successfull");
    return mCursor;
}

public Cursor getColsById(String id) throws SQLException {
    Cursor mCursor = odb.query(DATABASE_TABLE, new String[] { KEY_TIMESTAMP,
            KEY_UNIQUEID,KEY_DEVICETYPE }, KEY_RSSI + " = " + id, null, null, null, null);
    Log.e("getallcols zmv", "opening successfull");
    return mCursor;
}
}

also my MainActivity.java code is here. Here i try to insert the data into database by making use of submit button. When i hit submit button the app does not stay for long time and says unfortunately myapp has stopped.my curious concern has been is my database being created or not?

please do help me thanks

public class MainActivity extends Activity {

private ListView list_lv;
private EditText txt1;
private EditText txt2;
private EditText txt3;
private EditText txt4;
private Button btn1;
private Button btn2;
private DBclass db;

private ArrayList<String> collist_1;
private ArrayList<String> collist_2;
private ArrayList<String> collist_3;
private ArrayList<String> collist_4;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    collist_1 = new ArrayList<String>();
    collist_2 = new ArrayList<String>();
    collist_3 = new ArrayList<String>();
    collist_4 = new ArrayList<String>();


    items();
   // getData();
}

private void items() {
    btn1 = (Button) findViewById(R.id.button1);
    btn2 = (Button) findViewById(R.id.button2);
    txt1 = (EditText) findViewById(R.id.editText1);
    txt2 = (EditText) findViewById(R.id.editText2);
    txt3 = (EditText) findViewById(R.id.editText3);
    txt4 = (EditText) findViewById(R.id.editText4);
   // list_lv = (ListView) findViewById(R.id.dblist);

    btn2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
          //getData();
            viewData();
        }

        private void viewData() {
            Intent i = new Intent(MainActivity.this, viewActivity.class);
            startActivity(i);


        }
    });

    btn1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            submitData();
        }
    });
}

protected void submitData() {
    int a = Integer.parseInt( txt1.getText().toString());
    int b = Integer.parseInt( txt2.getText().toString());
    String c = txt3.getText().toString();
    int d = Integer.parseInt( txt4.getText().toString());

    db = new DBclass(this);

    long num = 0;
    try {
        db.open();
        num = db.insertrecord(a, b,c,d);
        db.close();
    } catch (SQLException e) {
         Toast.makeText(this, "Error Duplicate value"+e,2000).show();

    } finally {
        //getData();
    }
    if (num > 0)
        Toast.makeText(this, "Row number: " + num, 2000).show();
    else if (num == -1)
        Toast.makeText(this, "Error Duplicate value", 4000).show();
    else
        Toast.makeText(this, "Error while inserting", 2000).show();
}

I learning Android Sliding Menu using Navigation Drawer From http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/ . This tutorial, sample code works started in android 3.0 or Honeycomb. I want to make it work on android 2.3.3. Then I followed this tutorial http://hmkcode.com/add-actionbar-to-android-2-3-x/. Here's what I've done:

  1. I've changed the "Activity" to "ActionBarActivity".
  2. Then change the "gettActionBar ()" to "getSupportActionBar ().
  3. Sets Style on Manifest to "@ style / Theme.AppCompat.Light
  4. Well as adding Compabiltiy android v 7 Support

This code has been changed package info.androidhive.slidingmenu;

import info.androidhive.slidingmenu.adapter.NavDrawerListAdapter;
import info.androidhive.slidingmenu.model.NavDrawerItem;

import java.util.ArrayList;

import android.app.Fragment;
import android.app.FragmentManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

public class MainActivity extends ActionBarActivity {
    private DrawerLayout mDrawerLayout;
    private ListView mDrawerList;
    private ActionBarDrawerToggle mDrawerToggle;

    // nav drawer title
    private CharSequence mDrawerTitle;

    // used to store app title
    private CharSequence mTitle;

    // slide menu items
    private String[] navMenuTitles;
    private TypedArray navMenuIcons;

    private ArrayList<NavDrawerItem> navDrawerItems;
    private NavDrawerListAdapter adapter;

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

        // load slide menu items
        navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);

        // nav drawer icons from resources
        navMenuIcons = getResources()
                .obtainTypedArray(R.array.nav_drawer_icons);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerList = (ListView) findViewById(R.id.list_slidermenu);

        navDrawerItems = new ArrayList<NavDrawerItem>();

        // adding nav drawer items to array
        // Home
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
        // Find People
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
        // Photos
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
        // Communities, Will add a counter here
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1), true, "22"));
        // Pages
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
        // What's hot, We  will add a counter here
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1), true, "50+"));


        // Recycle the typed array
        navMenuIcons.recycle();

        mDrawerList.setOnItemClickListener(new SlideMenuClickListener());

        // setting the nav drawer list adapter
        adapter = new NavDrawerListAdapter(getApplicationContext(),
                navDrawerItems);
        mDrawerList.setAdapter(adapter);

        // enabling action bar app icon and behaving it as toggle button
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);

        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                R.drawable.ic_drawer, //nav menu toggle icon
                R.string.app_name, // nav drawer open - description for accessibility
                R.string.app_name // nav drawer close - description for accessibility
        ) {
            public void onDrawerClosed(View view) {
                getSupportActionBar().setTitle(mTitle);
                // calling onPrepareOptionsMenu() to show action bar icons
                invalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
                getSupportActionBar().setTitle(mDrawerTitle);
                // calling onPrepareOptionsMenu() to hide action bar icons
                invalidateOptionsMenu();
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        if (savedInstanceState == null) {
            // on first time display view for first nav item
            displayView(0);
        }
    }

    /**
     * Slide menu item click listener
     * */
    private class SlideMenuClickListener implements
            ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
            // display view for selected nav drawer item
            displayView(position);
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // toggle nav drawer on selecting action bar app icon/title
        if (mDrawerToggle.onOptionsItemSelected(item)) {
            return true;
        }
        // Handle action bar actions click
        switch (item.getItemId()) {
        case R.id.action_settings:
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }

    /* *
     * Called when invalidateOptionsMenu() is triggered
     */
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        // if nav drawer is opened, hide the action items
        boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
        menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
        return super.onPrepareOptionsMenu(menu);
    }

    /**
     * Diplaying fragment view for selected nav drawer list item
     * */
    private void displayView(int position) {
        // update the main content by replacing fragments
        Fragment fragment = null;
        switch (position) {
        case 0:
            fragment = new HomeFragment();
            break;
        case 1:
            fragment = new FindPeopleFragment();
            break;
        case 2:
            fragment = new PhotosFragment();
            break;
        case 3:
            fragment = new CommunityFragment();
            break;
        case 4:
            fragment = new PagesFragment();
            break;
        case 5:
            fragment = new WhatsHotFragment();
            break;

        default:
            break;
        }

        if (fragment != null) {
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
                    .replace(R.id.frame_container, fragment).commit();

            // update selected item and title, then close the drawer
            mDrawerList.setItemChecked(position, true);
            mDrawerList.setSelection(position);
            setTitle(navMenuTitles[position]);
            mDrawerLayout.closeDrawer(mDrawerList);
        } else {
            // error in creating fragment
            Log.e("MainActivity", "Error in creating fragment");
        }
    }

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

    /**
     * When using the ActionBarDrawerToggle, you must call it during
     * onPostCreate() and onConfigurationChanged()...
     */

    @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 toggls
        mDrawerToggle.onConfigurationChanged(newConfig);
    }

}

this is HomeFragment

package info.androidhive.slidingmenu;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class HomeFragment extends Fragment {

    public HomeFragment(){}

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_home, container, false);

        return rootView;
    }
}

After I do the above, I still get the error java.lang.NoClassDefFoundError: info.androidhive.slidingmenu.HomeFragment and may be other fragment. So what should I do again? Thanks.. Sorry For my english

I write an simple layout which have and EditText, but it showing following warning message,

“No label views point to this text field”

While searching I got this and it solve that warning message as well. But did not got difference between both attribute android:id and android:labelFor. Any clarification !

I am trying to run the following command in Runtime exec():

Process p;
            try {
                p = Runtime.getRuntime().exec("arp -a");
                BufferedReader in = new BufferedReader(
                        new InputStreamReader(p.getInputStream()));

                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    if (!inputLine.contains("incomplete")) {

                        found++;
                        inputLine = cleanResult(inputLine);
                        storeList(inputLine);
                    }

                }
                in.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Log.e("check",e.getMessage());
            }

And the error that I'm getting is:

    07-14 12:23:16.548: W/System.err(14272): java.io.IOException: Error running exec(). Command: [arp, -n] Working Directory: null Environment: null
07-14 12:23:16.668: W/System.err(14272):    at java.lang.ProcessManager.exec(ProcessManager.java:211)
07-14 12:23:16.668: W/System.err(14272):    at java.lang.Runtime.exec(Runtime.java:168)
07-14 12:23:16.668: W/System.err(14272):    at java.lang.Runtime.exec(Runtime.java:241)
07-14 12:23:16.668: W/System.err(14272):    at java.lang.Runtime.exec(Runtime.java:184)
07-14 12:23:16.678: W/System.err(14272):    at com.app.president.FindDevices$8.run(FindDevices.java:225)
07-14 12:23:16.678: W/System.err(14272):    at android.os.Handler.handleCallback(Handler.java:725)
07-14 12:23:16.678: W/System.err(14272):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-14 12:23:16.678: W/System.err(14272):    at android.os.Looper.loop(Looper.java:137)
07-14 12:23:16.678: W/System.err(14272):    at android.app.ActivityThread.main(ActivityThread.java:5099)
07-14 12:23:16.678: W/System.err(14272):    at java.lang.reflect.Method.invokeNative(Native Method)
07-14 12:23:16.678: W/System.err(14272):    at java.lang.reflect.Method.invoke(Method.java:511)
07-14 12:23:16.678: W/System.err(14272):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
07-14 12:23:16.678: W/System.err(14272):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
07-14 12:23:16.678: W/System.err(14272):    at dalvik.system.NativeStart.main(Native Method)
07-14 12:23:16.678: W/System.err(14272): Caused by: java.io.IOException: Permission denied
07-14 12:23:16.678: W/System.err(14272):    at java.lang.ProcessManager.exec(Native Method)
07-14 12:23:16.678: W/System.err(14272):    at java.lang.ProcessManager.exec(ProcessManager.java:209)
07-14 12:23:16.688: W/System.err(14272):    ... 13 more

The LOG that I have put for check reads:

07-14 12:23:19.971: E/check(14272): Error running exec(). Command: [arp, -a] Working Directory: null Environment: null

What this code does is, it tries to read the arp cache to fetch all MAC address with their respective IP addresses.

Can someone please help me with this and get my code running. I want to know why is the following code giving this error? Are there any permissions required for doing this? The permission I have granted till now are:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

Thanks in advance :)

My app is collecting data from server and it is getting crashed on a particular device , while it is working fine on other device with same OS 4.4.2 and log is showing require SET_PROCESS_LIMIT in manifest, is that we have to add that permission in manifest

I send notification one client to another successfully. With this method:

ParsePush push = new ParsePush();
String yourMessage = "hello world";
push.setChannel("seconddevice");
push.setMessage(yourMessage);
push.sendInBackground();

my application:

public class ParseApplication extends Application {
    String YOUR_APPLICATION_ID="xxx",YOUR_CLIENT_KEY="yyy";

    @Override
    public void onCreate() {
        super.onCreate();

        // Add your initialization code here
        Parse.initialize(this, YOUR_APPLICATION_ID, YOUR_CLIENT_KEY);


        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();

        // If you would like all objects to be private by default, remove this line.
        defaultACL.setPublicReadAccess(true);

        ParseACL.setDefaultACL(defaultACL, true);

        PushService.subscribe(this, DEVICE_NAME, NotificationBck.class);


    }

}

It works. But when I receive message in second device can I have which device send this notification?

I have a method in a .jar that I'd like to call in Unity's Start() for a Unity Android build. What's the easiest way to go about this?