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?

So, I implemented a Android Expandable List View http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial.

The only different to me is that i need to prepare my list of data. I have to do some implementations on the prepareListData() (I suppose)

On my table from sqlite I've got 3 columns (id, value and date). For each different month i want to make a Header for my expandable listview and inside of that put the values for that month.

How can i do that?

Cumps

I have a button that is in a table, but the button stretches across the screen, thereby stretching my image, making it ugly. I have tried wrap_content, fill_parent, and match_parent but they all give the same result. Here is my xml. Why doesn't the button reduce it's size???

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


                   <TableRow>
                     <ImageView
                             android:contentDescription="@string/contents"
                             android:id="@+id/imageView1"
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:layout_gravity="center_horizontal|top"
                             android:paddingTop="10dp"
    android:src="@drawable/lesson1" />
  </TableRow>

  <TableRow>

      <TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/alpha"
          android:paddingLeft="15dp"
          android:textAppearance="?android:attr/textAppearanceLarge" />

  </TableRow>


  <TableRow>
        <TextView
          android:id="@+id/textView3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingLeft="15dp"
          android:textStyle="italic"
          android:text="@string/alphanote"
          android:textAppearance="?android:attr/textAppearanceMedium" />

  </TableRow>


  <TableRow>
      <TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/directions2"
          android:paddingLeft="15dp"
          android:textAppearance="?android:attr/textAppearanceMedium" />

  </TableRow>

  <TableRow>

      <Button
          android:id="@+id/Button1"
          android:layout_width="14dp"
          android:background="@drawable/playstart" />

  </TableRow>

  <TableRow>
      <TextView
          android:id="@+id/textView4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/alpha1"
          />

      </TableRow>
        </TableLayout>     
     </ScrollView>

I'm receiving the error No such table in SQLite for Android. Does anyone know why?

My String Holder Class:

public class DataBaseStringHolder {

  public static final String DATABASE_NAME = "contacts.db";
  public static final String TABLE_NAME = "contacts";
  public static final String KEY_ID = "_id";
  public static final String NAME = "name";
  public static final String PHONE_NUMBER = "phone_number";

  public static int DATABESE_VERSION = 1;

}

public class DataBaseOpenHelper extends SQLiteOpenHelper {

  public DataBaseOpenHelper(Context context, String name,
      CursorFactory factory, int version) {
    super(context, name, factory, version);
    // TODO Auto-generated constructor stub
  }


  @Override
  public void onCreate(SQLiteDatabase arg0) {

    String CREATE_BOOKS_TABLE = "CREATE TABLE " + DataBaseStringHolder.TABLE_NAME + "("
                + DataBaseStringHolder.KEY_ID + " INTEGER PRIMARY KEY,"
        + DataBaseStringHolder.NAME + " TEXT,"
                + DataBaseStringHolder.PHONE_NUMBER + " TEXT," + ")";

      arg0.execSQL(CREATE_BOOKS_TABLE);

  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + DataBaseStringHolder.TABLE_NAME);
    onCreate(db);
  }

}



public class DataBaseHandler {

  public DataBaseOpenHelper dbOpenHelper;

  public DataBaseHandler(Context c){
    dbOpenHelper = new DataBaseOpenHelper(c, DataBaseStringHolder.DATABASE_NAME, null, DataBaseStringHolder.DATABESE_VERSION);
  }

  public Cursor getAllContacts(){
    SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
    Cursor cursor = db.query(DataBaseStringHolder.TABLE_NAME, null, null, null, null, null, null);
    return cursor;

  }

  public void insertData(String name, String phoneNumber){
    SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
    ContentValues cv = new ContentValues();
    cv.put(DataBaseStringHolder.NAME, name);
    cv.put(DataBaseStringHolder.PHONE_NUMBER, phoneNumber);
    db.insert(DataBaseStringHolder.TABLE_NAME, null, cv);
    db.close();
  }
}

Here is my Main Activity:

public class MainActivity extends Activity {

  TextView tvShowAll;
  StringBuilder strBldr;
  Cursor cursor;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    DataBaseHandler dbHandler = new DataBaseHandler(this);

    dbHandler.insertData("Artyom", "0524077960");
    dbHandler.insertData("Julia", "893276498");
    dbHandler.insertData("wefwe", "2123123123");
    try{
    cursor = dbHandler.getAllContacts();
    this.startManagingCursor(cursor);
    }catch(Exception e){
      Toast.makeText(MainActivity.this, "Cannot open getAllContactsMethod", Toast.LENGTH_SHORT).show();
    }
    cursor.moveToFirst();

    try{
    while(cursor.moveToNext()){
      strBldr =new StringBuilder();
      strBldr.append(cursor.getInt(0));
      strBldr.append(cursor.getString(1));
      strBldr.append(cursor.getString(2));
      strBldr.append("\n");
    }
    tvShowAll = (TextView)findViewById(R.id.tvShowAll);
    tvShowAll.setText(strBldr);
    }catch(Exception e){
      Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_SHORT).show();
    }
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

}

I am trying to estamblish a communication between Android phone and TI CC2540.

From a popup dialog the device is selected after this I would like to run a service to handle the communication. I tried the following code however this never gets into the onServiceConnected function. How can I fix this? The other question is how can I exchange data between the Activity and the Service?

private void ConnectToDevice() {
     mServiceConnection = new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName componentName, IBinder service) {


                mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
                if (!mBluetoothLeService.initialize()) {
                    Log.e("BLE", "Unable to initialize Bluetooth");
                    finish();
                }
                // Automatically connects to the device upon successful start-up initialization.
                mBluetoothLeService.connect(mDeviceAddress);
                Log.d("BLE", "Connected");

            }

            @Override
            public void onServiceDisconnected(ComponentName componentName) {
                mBluetoothLeService = null;
            }
        };


    final Intent intent = getIntent();        
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
    startActivity(intent);

}

I am trying to write testcase for app download-install scenario for an application. I could click on the ListView item to download the app and then click again to install the app. It brings up Android native screen 'Do you want to install this application?' with 'Cancel' and 'Install' button.

My problem is, how do i programmatically perform click on this 'Install' button?

Thanks!!

Do Android apps written 100% in C or C++ using the manifest to specify a native activity with android: hasCode="false" have a .dex file in the apk?

I have a custom layout in a file called cat.xml and I am using this layout in an alert dialog box. What I have so far is this:

 LayoutInflater inflater = getLayoutInflater();
    View dialoglayout = inflater.inflate(R.layout.cat, null);
    alertDialogBuilder.setView(dialoglayout);
    alertDialogBuilder.setCancelable(false);
    View v1=null;
    v1=inflater.inflate(R.layout.cat,null);
    Button b1;
    b1= (Button)v1.findViewById(R.id.buttonALL25);

    b1.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v) {

            Log.d("NICK","ALL 25 clicked");
        }
    });

and my app will compile but when running and clicking on the button my log statement never shows up so I assume that what I have is incorrect. So my question is what is the proper way to reference the button from the inflated layout in order to have a click listener for it.

Please don't downvote without leaving a comment. It isn't helpful without any feedback.

Using JavaCameraView in OpenCV, I only get 14 frame per second. No calculation is done. Neither image processing, nor feature detection. Only receiving the camera frame intact. But FPS doesn't go over 14. Why is that?

Is it bad implementation or I'm missing something?

I have a full screen VideoView, which has a MediaController associated. I want to detect when the user clicks on the MediaController seekbar.

VideoView video;
MediaController mc;


video = (VideoView) findViewById(R.id.fullVideoView);
video.setVideoPath(url);
mc = new MediaController(this);
mc.setAnchorView(video);
mc.setMediaPlayer(video);

final int topContainerId1 = getResources().getIdentifier("mediacontroller_progress", "id", "android");
final SeekBar seekbar = (SeekBar) mc.findViewById(topContainerId1);

seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    Toast.makeText(FullScreenVideo.this, "you are detecting something",Toast.LENGTH_LONG).show();
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    Toast.makeText(FullScreenVideo.this, "you are detecting something else",Toast.LENGTH_LONG).show();
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
    Toast.makeText(FullScreenVideo.this, "and something else",Toast.LENGTH_LONG).show();
    }
});

video.setOnPreparedListener(PreparedListener);
video.setMediaController(mc);

I have read a lot off documentation about how to access to the MediaController seekbar, but the way I read (the way I am doing) does not work properly. The seekbar doesn't detect anything. what am I doing wrong? I would appreciate any idea! Thanks!

I'm a icons themer for Android and unfortunately I'm not very familiar with programming languages.

My problem is with a file. Xml "appfilter.xml."

Through this xml, in addition to declaring the drawable for the various "activities" that I designed, there is also the possibility to define a scale factor so that the icons that I have not drawn, are scaled and placed in a "iconback" (a basic icon with the theme of equal basis equal to the other), in order to give a more linear look.

What I need is I can not define, as well as the scale factor, although the exact location of where the original icon is put in my iconback. By default, only defining the scale factor, it is placed centrally, but I want it in a different location.

how could I do to get full control over the position of the icons do not draw from me in the "iconback"?

Thank you all for the help.

I am working on swipe views and tab vies in Android Studio and while looking for help online i found the following code:

public static player newInstance(int sectionNumber) {

    player fragment = new player();
    Bundle args = new Bundle();
    args.putInt(ARG_SECTION_NUMBER, sectionNumber);
    fragment.setArguments(args);

    return fragment;
  }

However when i deleted this code the application worked as expected.

Can you please tell me what this code is exactly doing as I am only a beginner yet

Thanks alot

I have written the following code for detecting the network status from within the BroadcastReceiver. I start a service when the network is available and stop the service when the network is not available.

I have the following class level variable.

private boolean IsNetworkAlreadyConnected = false;

Within onCreate method of the main class I start the service if the internet is available.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (InternetConnectivity.isConnected(MainActivity.this)) {
                IsNetworkAlreadyConnected = true;

                Intent timerIntent = new Intent(getBaseContext(), InActivityTimer.class);
                startService(timerIntent);
            }
}

and below is the code for my BroadcastReceiver in the same class,

public class mConnectivityCheckReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();

        if (action.equals("android.net.conn.CONNECTIVITY_CHANGE")) {

            try {
                boolean networkAvailable = InternetConnectivity.isConnected(context);

                if (networkAvailable) {
                    if (!IsNetworkAlreadyConnected) {   
                        Intent timerIntent = new Intent(getBaseContext(), InActivityTimer.class);
                        startService(timerIntent);
                        IsNetworkAlreadyConnected = true;
                    } 
                    else {
                        Log.d("KC_HomeActivity", "Network was already connected. No need to start service again.");
                    }
                }
                else {

                    Log.d("KC_HomeActivity", "Network Disconnected. Service Stopped.");
                    IsNetworkAlreadyConnected = false;
                    Intent timerIntent = new Intent(getBaseContext(), InActivityTimer.class);
                    stopService(timerIntent);
                }
            }
            catch (Exception e) {
            }
        }
    }
};

When both Mobile data and Wifi are turned on then the service is started from onCreate method and it is not started again in the BroadcastReceiver but when I turn off the Wifi the Android changes the network mode to Mobile Data but for few seconds there is no internet connectivity and the service is stopped and then started again. I don't want to do this. If there is no connectivity only then the service should be stopped. If the network is shifting from Wifi to Mobile Data then the service should not be stopped.

Note: To check the internet connectivity I am using,

NetworkInfo info = InternetConnectivity.getNetworkInfo(context);
return (info != null && info.isConnectedOrConnecting()); 

package com.alexatwater.elhsapcalc;

import android.R.anim;
import android.app.Application;
import android.text.AndroidCharacter;
import android.util.Log;

import com.parse.*;

public class App extends Application { 

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

        Parse.initialize(this, "Z3T4v6PoKP78FXu9qyyuoLvq9SbOd7Z1dptwGenI", "5WYuDH5xn89Sqqe1noKgUjVx112sA0lBWecXVO1d"); 
    }

    public void registerForPush() {

        Log.d("registerPush", "1");

        PushService.setDefaultPushCallback(this, NewsActivity.class);

        //set class to goto
        Log.d("error", "2");
        //register with parse.com
        //ParseInstallation currentInstallation = ParseInstallation.getCurrentInstallation();
        //      
        //currentInstallation.

        ParseInstallation.getCurrentInstallation().put("hardwareType", android.os.Build.MODEL.toString());
        ParseInstallation.getCurrentInstallation().put("systemVersion", android.os.Build.VERSION.RELEASE.toString());
        ParseInstallation.getCurrentInstallation().saveInBackground();
        Log.d("parse.com", "Registered for push. Analytics logged");
    }

} 

Here is the code. The issue that I'm having is this line:

PushService.setDefaultPushCallback(this, NewsActivity.class);

If I put it in the onCreate() method, the second that the app is open, the device will receive push notifications from parse.com. That’s not what I wanted. There is a validation screen they must pass until they can receive push notifications. What I have is a method below that is called from the validation activity once they pass validation. That method WORKS and IS CALLED, but by having that one line of code there, the app crashes with a NullPointerException. Anyone have any idea what could be wrong or what I could do to achieve push with validation?

I am facing EXTREMELY PECULIAR problem with my android application. I see not a single similar solution anywhere, either on google or on SO.

Here is my screenshot of the app: enter image description here

This is normal expected output. But when I exit the app and resume again from launcher, often(say 2 out of 5 times) I happen to get the white components(list view and EditText) like this:

enter image description here

In this image, I have touched the first element of listview while taking screenshot so that its shown that the listview items are having actual content and not empty.

Here is my layout resource file main.xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/ll"
              android:cacheColorHint="#00000000"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent" android:weightSum="15" android:background="@android:color/white">


    <EditText
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:id="@+id/edittext" android:layout_weight="2" android:background="#ffffff"
            android:textColor="@android:color/black" android:gravity="center" android:hint="Enter Your Text Here"/>
    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp" android:layout_weight="2"
            android:weightSum="12" android:gravity="center">
        <Button android:layout_width="0dp"
                android:layout_height="match_parent"
                android:text="Tweet"
                android:id="@+id/tweetbtn"
                android:background="@drawable/mybutton"
                android:layout_weight="6"/>
        <Button
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:text="Search"
                android:background="@drawable/mybutton"
                android:id="@+id/searchbtn"
                android:layout_weight="6"/>
    </LinearLayout>
    <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:text="Most Frequently Tweeted"
            android:id="@+id/listviewlabel" android:layout_weight="1" android:gravity="center" android:background="#adadad"
            android:textColor="@android:color/black"/>
    <ListView
            android:cacheColorHint="#00000000"
            android:background="#ffffff"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:id="@+id/listView" android:layout_gravity="center_horizontal" android:layout_weight="10"
            android:choiceMode="singleChoice"/>
</LinearLayout>

Please someone help me out with this. Atleast help me resolve the white EditText issue first. That will give me alteast a clue to solve the listview issue.

EDIT: The listview is dynamically populated by elements. Here is my onStart() method:

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

        handleFrequentMenuSelected();
    }

Here is the handleFrequentMenuSelected():

private void handleFrequentMenuSelected() {
        if(!isAccountAdded()){
            showToast("Add an account first to get started! Goto Menu and select account.");
        }else{
            List<StatusElement>aList=getStatusElementsFromSQLiteDatabase();
            HashMap<String,Integer> hMap=new HashMap<String, Integer>();
            for(StatusElement s:aList){
                String tokens[]=s.toString().split(" ");
                String outText="";
                if(tokens.length>1){
                    if(tokens[0].contains("/")){
                        String tokens2[]=tokens[0].split("/");
                        try{
                            long l=Long.parseLong(tokens2[0]);
                            for(int i=1;i<tokens.length;i++){
                                outText=outText+tokens[i]+" ";
                            }
                        }catch(Exception e){
                            outText=s.toString();
                        }
                    }else{
                        try{
                            long l=Long.parseLong(tokens[0]);
                            for(int i=1;i<tokens.length;i++){
                                outText=outText+tokens[i]+" ";
                            }
                        }catch(Exception e){
                            outText=s.toString();
                        }
                    }

                }else{
                    outText=s.toString();
                }
                outText=outText.trim();
                if(hMap.containsKey(outText)){
                    int cnt=hMap.get(outText);
                    cnt++;
                    hMap.put(outText,cnt);
                }else{
                    hMap.put(outText,1);
                }
            }
            hMap= (HashMap<String, Integer>) StaticConstants.sortByValue(hMap);
            ArrayList<String>tweets=new ArrayList<String>();
            ArrayList<Integer>frequencies=new ArrayList<Integer>();
            ArrayAdapter<String>adapter;

            int count=0;
            for(String s:hMap.keySet()){
                tweets.add(s);
                frequencies.add(hMap.get(s));
                count++;
                if(count==50)
                    break;
            }
            adapter=new MyCustomFrequentArrayAdapter(this,tweets,frequencies);
            listView.setAdapter(adapter);
            listViewLabel.setText("Most Frequent Tweets");
            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, final View view,
                                        int position, long id) {
                    final String item = (String) parent.getItemAtPosition(position);
                    editText.setText(System.currentTimeMillis()+" "+item);
                }
            });
        }
    }

Here is my MyCustomFrequentArrayAdapter:

class MyCustomFrequentArrayAdapter extends ArrayAdapter<String> {
        private final Context context;
        private final ArrayList<String> values;
        private final ArrayList<Integer>frequencies;

        public MyCustomFrequentArrayAdapter(Context context, ArrayList<String> values,ArrayList<Integer>frequencies) {
            super(context, R.layout.customlistview, values);
            this.context = context;
            this.values = values;
            this.frequencies=frequencies;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView = inflater.inflate(R.layout.customlistview, parent, false);
            TextView textView1 = (TextView) rowView.findViewById(R.id.firstLine);
            TextView textView2 = (TextView) rowView.findViewById(R.id.secondLine);
            Log.d("Position",""+position);
            //Extracting first six words
            String s=values.get(position);
            String tokens[]=s.split(" ");
            String dispText="";
            if(tokens.length>6){
                for(int i=0;i<6;i++){
                    dispText=dispText+tokens[i]+" ";
                }
            }else{
                dispText=s;
            }
            textView2.setText(dispText);
            textView1.setText("Frequency:"+frequencies.get(position));
            return rowView;
        }
    }