I am using this code to capture sound data of my device,but how do I stop these functions from further capturing the data, nothing seems to work, the app gets stuck in a particular state.

    Visualizer mVisualizer = new Visualizer(0);
    mVisualizer.setEnabled(false);
    int capRate = Visualizer.getMaxCaptureRate();
    int capSize = Visualizer.getCaptureSizeRange()[1];
    mVisualizer.setCaptureSize(capSize);
    Visualizer.OnDataCaptureListener captureListener = new Visualizer.OnDataCaptureListener() {
        @Override
        public void onWaveFormDataCapture(Visualizer visualizer,
                byte[] bytes, int samplingRate) {

            Camera cam = Camera.open();
            Parameters params;
            int length = bytes.length;
            for (int i = 0; i < length; i++) {
                Log.d("neela", "peela");


                if (bytes[i] > 90 || bytes[i] <= -90) {
                    Log.d("hehe", "pepe");
                    params = cam.getParameters();
                    params.setFlashMode(Parameters.FLASH_MODE_OFF);
                    cam.setParameters(params);
                    cam.stopPreview();

                } else {

                    params = cam.getParameters();
                    params.setFlashMode(Parameters.FLASH_MODE_TORCH);
                    cam.setParameters(params);
                    cam.startPreview();
                    Log.d("check", "control");
                }

            }
            if (cam != null) {
                cam.stopPreview();
                cam.release();
                cam = null;
            }

}

        @Override
        public void onFftDataCapture(Visualizer visualizer, byte[] bytes,
                int samplingRate) {
        }

    };

    int status = mVisualizer.setDataCaptureListener(captureListener,
            capRate, true/* wave */, false/* no fft needed */);
    mVisualizer.setEnabled(true);

}

The above code is the code for turnOnFlash() and works fine, but when I call the method turnOffFlash() nothing seems to work and app remains in the same state

    btnSwitch.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isFlashOn) {
                // turn off flash
                turnOffFlash();
            } else {
                // turn on flash
                turnOnFlash();
            }
        }
    });

I have the following object setup like so and pass in info to an Async task:

DynamoDBManager.CoreInfo passCoreInfo = new DynamoDBManager.CoreInfo();
passCoreInfo.setId(1);
passCoreInfo.setAttr("C3P0");
passCoreInfo.setMethodCallType("Get Info");

new DynamoDBManagerTask()
        .execute(passCoreInfo);

However, despite being passed in as an object it then somehow gets converted to CoreInfo[], but the return expects CoreInfo according to my error. I've tried changing the return type for doInBackground and AsyncTask to ArrayList so it'll expect an array, but it still expects CoreInfo and not CoreInfo[] at the return coreInfo line.

private class DynamoDBManagerTask extends
            AsyncTask<DynamoDBManager.CoreInfo, Void, DynamoDBManager.CoreInfo> {
        List<DynamoDBManager.Info1> info1Result = new ArrayList<DynamoDBManager.Info1>();
        List<DynamoDBManager.Info2> info2Result = new ArrayList<DynamoDBManager.Info2>();

        protected DynamoDBManager.CoreInfo doInBackground(
                DynamoDBManager.CoreInfo... coreInfo) {

            //If coreInfo[0].getMethodCallType.equals("Get Info"),  info1Result = call DynamoDB query 1
            //Else  info2Result = call DynamoDB query 2

            return coreInfo; // Should remain untouched, same info as when passed in
        }

        @Override
        protected void onPostExecute(DynamoDBManager.CoreInfo coreInfo) {

            //If coreInfo[0].getMethodCallType.equals("Get Info"), save info1Result to SQLite table 1
            //Else save info2Result to SQLite table2            
        }
    }

How can I fix my code so that the types line up? And it doesn't throw the Required: CoreInfo Found: CoreInfo[] error?

I am learning Android and now i have lesson about the database - PetTracker.

http://androidsvnex.googlecode.com/svn/trunk/androidsvnex/PetListTracker/src/kr/co/sqlite/persistent/pet/PetDatabase.java

I use Eclipse + my phone for testing.

I would like rename field in this app and this working ok, but if i run application after changes then i have error - field not exist, but if i unninstall app on my phone and again run app then this working ok.

So how can i make if i run as application then database should be also updated?

Folks,

I need to capitalize first letter of every sentence. I followed the solution posted here

First letter capitalization for EditText

It works if I use the keyboard. However, if I use setText() to programatically add text to my EditText, first letter of sentences are not capitalized.

What am I missing? Is there a easy way to fix or do I need to write code to capitalize first letters in my string before setting it to EditText.

I have searched all over the site, not getting any clue for the problem. I have created a Service which works fine when the app starts. When i bind, i get positive response but while calling service function, it throws an error where i have no clue.

The soul purpose of this service is to put a notification as an App Launcher or a shortcut. so it always shows in the notification bar when user doesn't want, they can stop showing in the notification by changing the preference.

Here is my Service Class

public class NoteService extends Service {

    private NotificationManager mNotificationManager;
    private Notification.Builder mNotification = null;
    private final IBinder mBinder = new LocalBinder();

    @Override
    public IBinder onBind(Intent intent) {
        Log.w("OnBind", "OK");
        return mBinder;
    }

    @Override
    public void onCreate() {


//These preference reading lines are to launch the notification shortcut by default(1st time running)
        SharedPreferences preference = PreferenceManager.getDefaultSharedPreferences(getApplication());

        boolean quickAccessFlag = preference.getBoolean("prefkey_quick_access", false);

        if (quickAccessFlag){
            launchQuickAccess();
        }

        super.onCreate();
    };

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return START_STICKY;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    private void initializeNotification(){
        try{
        mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        mNotification = new Notification.Builder(getApplicationContext());
        mNotification.setContentTitle(getString(R.string.notification_quick_write));
        mNotification.setContentText(getString(R.string.notification_quick_write_summary));
        mNotification.setSmallIcon(R.drawable.ic_launcher);
        mNotification.setOngoing(true);
        mNotification.setAutoCancel(false);
        Intent intent = new Intent(this, Write.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

        mNotification.setContentIntent(pendingIntent);
        }catch(Exception e){e.printStackTrace();}
    }

    public void launchQuickAccess(){
        Log.w("Bind", "Service call to start");
        if (mNotificationManager == null){
            initializeNotification();
        }
        mNotificationManager.notify(0, mNotification.build());
    }

    public void abortQuickAccess(){
        Log.w("Bind", "Service call to abord");
        mNotificationManager.cancelAll();
    }

    public class LocalBinder extends Binder{

        public NoteService getNoteService(){
            return NoteService.this;
        }

    }

}

Here is my Binding code inside the Activity'

//Connection Initialization
ServiceConnection serviceConnection = new ServiceConnection() {

    @Override
    public void onServiceDisconnected(ComponentName arg0) {

    }

    @Override
    public void onServiceConnected(ComponentName arg0, IBinder arg1) {

        LocalBinder binder = ((NoteService.LocalBinder)arg1);
        mBinder = binder.getNoteService();

    }
};

//Binding after starting the Service

startService(new Intent(getBaseContext(), NoteService.class));

//Biding return value is true
bindService(new Intent(Settings.this, NoteService.class ), serviceConnection , Context.BIND_AUTO_CREATE);

mBinder.launchQuickAccess(); //Error Throws from this line

Here is my Manifest Registration

<service android:name="com.xlabs.Notes.NoteService"
            android:process=":NService" />

Hi fellow coders I developed and app and tried to upload it to the google play store with an AndroidManifest.xml having the following permission and access in it:

 <receiver android:name=".MyAdmin" android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data android:name="android.app.device_admin" android:resource="@layout/policies">
            <intent-filter>
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED">
            </action></intent-filter>
        </meta-data></receiver>

and then I received the following email from the Google Developers Support:

This is a notification that your application, XVse, with package ID com.example.XVse, has been removed from the Google Play Store.

REASON FOR REMOVAL: Violation of the dangerous products provision of the Content Policy:

We don't allow content that harms, interferes with the operation of, or accesses in an unauthorized manner, networks, servers, or other infrastructure. After a regular review, we have determined that your app has a malformed AndroidManifest.xml file which may make it difficult for users to uninstall the app.

In particular, the app’s AndroidManifest.xml contains a malformed Device Admin receiver entry (as identified by meta-data named android.app.device_admin). To be a well-formed Device Admin, the entry must declare an Intent filter for Intents with action android.app.action.DEVICE_ADMIN_ENABLED. The suggested modification is to make the entry well-formed if the receiver is a Device Admin, or remove the meta-data named android.app.device_admin if the receiver is not a Device Admin.

All violations are tracked. Serious or repeated violations of any nature will result in the termination of your developer account, and investigation and possible termination of related Google accounts. If your account is terminated, payments will cease and Google may recover the proceeds of any past sales and the cost of any associated fees (such as chargebacks and payment transaction fees) from you.

i am trying to create a very simple programme of just displaying a fragment but am getting an error everytime i try to build the app

Here is the error

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\user2435\Android Studio\sdk\build-tools\19.1.0\dx.bat --dex --num-threads=4 --output C:\Users\user2435\AndroidStudioProjects\TheSingleFragment\app\build\intermediates\dex\debug C:\Users\user2435\AndroidStudioProjects\TheSingleFragment\app\build\intermediates\classes\debug C:\Users\user2435\AndroidStudioProjects\TheSingleFragment\app\build\intermediates\dependency-cache\debug C:\Users\user2435\AndroidStudioProjects\TheSingleFragment\app\build\intermediates\pre-dexed\debug\android-support-v4-0c4016dfc8794ad67faea3f8cc8fd3b23877990c.jar C:\Users\user2435\AndroidStudioProjects\TheSingleFragment\app\build\intermediates\pre-dexed\debug\classes-246e6497d26ce8d821cff4be0c3f291182761f73.jar C:\Users\user2435\AndroidStudioProjects\TheSingleFragment\app\build\intermediates\pre-dexed\debug\support-v4-19.1.0-2cb0dcfa5e76d3d31cbc2cb35eb1e5ce1cc3a125.jar Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) at com.android.dx.command.dexer.Main.run(Main.java:230) at com.android.dx.command.dexer.Main.main(Main.java:199) at com.android.dx.command.Main.main(Main.java:103)

Here is the activity:

    package com.whosaidthat.endos.thesinglefragment;

import android.app.Activity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;


public class MyActivity extends ActionBarActivity {


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

        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        MyFragment myFragment = new MyFragment();
        fragmentTransaction.add(R.id.fragmentContainer, myFragment);
        fragmentTransaction.commit();


    }




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

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

And here is the fragment it should display

  package com.whosaidthat.endos.thesinglefragment;

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

/**
 * Created by user2435 on 23/07/2014.
 */
public class MyFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_single, container, false);
    }
}

Any ideas why this is happening, i am trying to test it with my nexus 7 device. If it helps, i have also added the support .jar file from my sdk folder into the libs folder as i was told i need to do this to use the support files

Thanks

I have made a maze game for Android where you control a ball by tilting the phone in the direction the ball should roll.

I integrate the x and y acceleration to get the speed and then set the new position of the ball as currentPositionX += speedX; and currentPositionY += speedY;.

This works but not great, if I try to roll the ball in a circle it is more of an octagon. Therefore I am looking for a better integration method. I was suggested to use Runge Kutta or implicit integration but do not really know the math so I am unsure.

I found some code for Runge Kutta: https://java.net/projects/cougarsquared/sources/svn/content/trunk/core/libraries/flanagan/integration/RungeKutta.java?rev=2236 Can I use this? What is the coupled differential equation I am trying to solve and how do I transform it so I can solve it with Runge Kutta?

For more background, see this post: Android: Achieving smooth roll of ball using accelerometer

I am creating an custom expandable list. In the header i have added an ImageButton. I want to show an AlertDialog when The Image Button is clicked. for this I have made another class AlerttoB that extends DialogFragment. Everything is working fine but to show the Alert Dialog i used myAlert.show(getFragmentManager(), "My Alert"); which gives an error: The method getFragmentManager() is undefined for the type new View.OnClickListener(){}

The code is given below, please someone tell how to show the alert dialog in this scenerio or any wayaround for getfragmentManager() over here. Thanks.

public class ExpandableListAdapter extends BaseExpandableListAdapter {

private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;


public ExpandableListAdapter(Context context, List<String> listDataHeader,
        HashMap<String, List<String>> listChildData) {
    this._context = context;
    this._listDataHeader = listDataHeader;
    this._listDataChild = listChildData;
}



@Override
public Object getChild(int groupPosition, int childPosititon) {
    return this._listDataChild.get(this._listDataHeader.get(groupPosition))
            .get(childPosititon);
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public View getChildView(int groupPosition, final int childPosition,
        boolean isLastChild, View convertView, ViewGroup parent) {

    final String childText = (String) getChild(groupPosition, childPosition);

    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this._context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_item, null);
    }

    TextView txtListChild = (TextView) convertView
            .findViewById(R.id.lblListItem);

    txtListChild.setText(childText);
    return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
    return this._listDataChild.get(this._listDataHeader.get(groupPosition))
            .size();
}

@Override
public Object getGroup(int groupPosition) {
    return this._listDataHeader.get(groupPosition);
}

@Override
public int getGroupCount() {
    return this._listDataHeader.size();
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
        View convertView, ViewGroup parent) {
    String headerTitle = (String) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this._context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_group, null);
    }

    TextView lblListHeader = (TextView) convertView
            .findViewById(R.id.lblListHeader);
    lblListHeader.setTypeface(null, Typeface.BOLD);
    lblListHeader.setText(headerTitle);


    ImageButton buttonAdd = (ImageButton) convertView.findViewById(R.id.imageButtonAdd);
    buttonAdd.setFocusable(false);
    buttonAdd.setOnClickListener(new OnClickListener(){
        public void onClick(View v){

            AlerttoB myAlert = new AlerttoB();
            myAlert.show(getFragmentManager(), "My Alert");






        }  
    });  

    return convertView;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}

AlertoB class code:

public class SmsBlackListAlertInput extends DialogFragment {

@Override
public Dialog onCreateDialog(Bundle savedInstanceState){

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.blocksendersms, null);
builder.setView(view);
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener(){

    @Override
    public void onClick(DialogInterface dialog, int which) {
        // TODO Auto-generated method stub
        Toast.makeText(getActivity(), "Negative Button was clicked", Toast.LENGTH_SHORT).show();
    }

});

builder.setPositiveButton(R.string.add, new DialogInterface.OnClickListener(){

    @Override
    public void onClick(DialogInterface dialog, int which) {
        // TODO Auto-generated method stub
        Toast.makeText(getActivity(), "Positive Button was clicked", Toast.LENGTH_SHORT).show();
    }

});

Dialog dialog = builder.create();
return dialog;

}

}

I'm creating menus in my game specially rectangles with rounded corners and borders. I can do this with a shape renderer but I cannot mix shape renderer and sprite batcher. At the moment my resolution seems to be using large shapes as PNG's and scaling them BUT on a lot of devices this produces blurry corners.

I've read my tutorials on Meshes, shaders, using the shape renderer after the sprite batch (complication layer and performance impact), 9-patch (Border goes blurry, can't do gradients properly)

In android it was fairly simple, we just define the shape in XML and it creates a nice crisp shape example: rounded rect with a border and a gradient.

Could anyone give me some advice as too how I would go about's creating a rounded rect with a gradient, preferably some easy to use implementation that could be used in a reusable class.

After adding a dependency to my Android Library from my app in android studio I receive many errors of the following kind.

My App module is dependent on my InterstitialAdLib android library.

I´m trying to write some text in different Texture objects in libGDX. Is it possible to merge fonts with Texture objects?

Does any modern tablets PCs or smartphones support capturing video via their cameras in 16 bit grayscale format?

I want to create pulse detector that uses video of the face like in this project - https://github.com/thearn/webcam-pulse-detector . But I looked into its method description (http://people.csail.mit.edu/mrub/papers/vidmag.pdf). 8 bit image depth is not enough for my idea.

I've put a file on a NanoHTTPD server like this:

private class WebServer extends NanoHTTPD {

    public WebServer()
    {
        super("hostname", 8080);
    }

    @Override
    public Response serve(String uri, Method method,
                          Map<String, String> header,
                          Map<String, String> parameters,
                          Map<String, String> files) {
        String answer = "";
        FileInputStream inputStream = null;
        try {
            inputStream = new FileInputStream(fileToUpload);
        }catch(Exception e){}
        return new NanoHTTPD.Response(Status.OK, mimeType, inputStream);
    }
}

How do I access that file in my web browser now?

How to convert a

ArrayList<Bitmap>

To a mp4 File and save it ?

(Didn't find something that works)

im trying to navigate to parent fragment after completing the action in the child fragment. im able to successfully navigate from parent to child but having trouble when going backwards. the code im using currently is

From Parent to Child

 public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.action_new:
                    FragmentManager.BeginTransaction()
                                   .Replace(Resource.Id.content_frame, EditAccountFragment.NewInstance())
                                   .AddToBackStack("AccountFragment")
                                   .Commit();                   
                    break;
            }
            return base.OnOptionsItemSelected(item);
        }  

From Child to Parent

public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.action_save:
                    SaveAccount();
                    GotoAccounts();
                    Toast.MakeText(Activity, "Save Account", ToastLength.Short).Show();
                    break;
                case Resource.Id.action_cancel:
                    GotoAccounts();
                    Toast.MakeText(Activity, "Save Account Cancelled", ToastLength.Short).Show();
                    break;
            }
            return base.OnOptionsItemSelected(item);
        }

        private void GotoAccounts()
        {

            AccountsFragment accountsFragment = new AccountsFragment();
            FragmentManager.BeginTransaction()
                                   .Replace(Resource.Id.content_frame, accountsFragment)
                                   .Commit();
        }

        private void SaveAccount()
        {
            Account.AccountName = Title.Text;
            Account.Note = Note.Text;
            _accountDM.SaveAccount(Account);
        }

Can anyone please help me in getting this work to navigate from Child to Parent? i want the user to redirect to listing page once he save the account in child fragment.

Thanks for all or Any help.

I have listview and Mediaplayer. It worked from resorce folder when I touch list. But, It didn't work and get error when I tried streaming from my google drive and url "sample3url" which someone prepeared as a test streaming.

Also, I tried three patterns in switch-case code.
Here is my code and error.
MediaPlayer﹕ error (1, -2147483648)


MediaController controller;
MediaPlayer mp;
Handler handler = new Handler();
ListView fishlist;

String sample1url = "https://drive.google.com/file/d/0B0ggrtD9yNRpUGNYQ3l6QTBqSGc/edit?usp=sharing";
String sample2url = "https://drive.google.com/file/d/0B0ggrtD9yNRpM1I0b3FMYkRXVHM/edit?usp=sharing";
String sample3url = "ia700200.us.archive.org/1/items/testmp3testfile/mpthreetest.mp3";

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

   ItemBean IB1 = new ItemBean();
     IB1.setName("sample1");
     IB1.setUrl("http~");

   ItemBean IB2 = new ItemBean();
    IB2.setName("sample2");
     IB2.setUrl("http~");

   ItemBean IB3 = new ItemBean();
    IB3.setName("sample3");
    IB3.setUrl("http~");

   List<ItemBean> list = new ArrayList<ItemBean>();
    list.add(IB1);
    list.add(IB2);
    list.add(IB3);

    mp = new MediaPlayer();
    controller = new MediaController(this);
    controller.setAnchorView(findViewById(R.id.mediaController));
    controller.setMediaPlayer(this);
    mp.setAudioStreamType(AudioManager.STREAM_MUSIC);

 list2 = (ListView) findViewById(R.id.song_list);
SonglistAdapter_test adapter = new SonglistAdapter_test(getApplicationContext(),list);
list2.setAdapter(adapter);
list2.setOnItemClickListener(this)
}

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
                        long id) {
    switch (position) {
        case 0:
            try{
            mp.setDataSource(sample1url);
        } catch (IllegalArgumentException e) {
            //
            e.printStackTrace();
        } catch (IllegalStateException e) {
            //
            e.printStackTrace();
        } catch (IOException e) {
            //
            e.printStackTrace();
        }
        try {
            mp.prepare();
        } catch (IllegalStateException e) {
            //
            e.printStackTrace();
        } catch (IOException e) {
            //
            e.printStackTrace();
        }
            break;

    case 1:
        try {
            mp.setDataSource(sample2url);
           mp.prepare();
        } catch  (IOException e) {}
        break;

        case 2:
        try {
            mp.setDataSource(sample3url);
        } catch (IllegalArgumentException e) {
            //
            e.printStackTrace();
        } catch (IllegalStateException e) {
            //
            e.printStackTrace();
        } catch (IOException e) {
            //
            e.printStackTrace();
        }
        try {
            mp.prepare();
        } catch (IllegalStateException e) {
            //
            e.printStackTrace();
        } catch (IOException e) {
            //
            e.printStackTrace();
        }
            break;
    }

    mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    controller.setEnabled(true);
                    controller.show(mp.getDuration());
                    mp.start();
                    try {
                        Method m = android.widget.MediaController.class.getDeclaredMethod("updatePausePlay");
                        m.setAccessible(true);
                        m.invoke(controller);
                    } catch (Exception e) {
                    }
                }
            });
        }
    });
}
@Override
public void start(){
    mp.start();
}

Android newbie here, had some quick questions:

How can you tell if your project is launching on a device?

Where do you see compilation errors? Just the event log?

How do you stop a project running on the device, and how can you tell if its stopped?

I have a Google Glass app that uses a CardScrollView to display a series of Cards.

Touch gestures work to move between cards, but I need to be able to jump to specific cards by their index. I want to use contextual voice commands (ignore its limitations for now) to do this, for example: "ok glass, go to card 25".

I was hoping to be able to do something like this...

CardScrollView mCardScrollView = new CardScrollView(this);
    // ...
    // "ok glass, go to card 25"
    // ...
mCardScrollView.setFocus(25);

...But I can't seem to find a function to do that.

I didn't find anything on Google's reference page: https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/widget/CardScrollView

And their sample code doesn't cover this either:
https://developers.google.com/glass/develop/gdk/ui-widgets#scrolling_cards_in_activities

I'd like to keep using CardScrollView if possible because I like the way it animates and scrolls compared to ViewFlipper or ViewPager. It's such a simple functionality that I believe should be there. Perhaps I'm missing something?

Hi I want to know the best way to go about this. I will put it in a simple counting app so its easier to explain.

I have 4 Buttons and 1 final Button which is the plus 1 Button. I also have 4 rows of Zero's. I want to make the first 4 Buttons like switches that change where to add the 1 to. So if button 1 is on and the plus 1 one is pressed then it would add the 1 the the zero in the first row, and if the 3rd button is then selected and the plus1 is pressed it would add the 1 the the 3rd row etc.

I also want the only one button at a time to be activated so if button 1 is on and the 4th button is pressed, it would turn off button 1 and turn on button 4 and in turn if the plus 1 is pressed it would add the 1 to the 4th row zero.

Any help would be much appreciated.

I'm trying to make an Android app that uses collision detection. To do this, I'm trying to set a rectangle to an ImageView. The only things I've found are ways to set a rectangle to a sprite or a specific point. One of the ImageViews that I need to detect moves across the screen even though it isn't a sprite. Is there a way to set a rectangle to an ImageView so I can detect when the two rectangles collide?

This is the code I used for making the ImageView move:

int x=brickimg.getRight()-brickimg.getLeft();
   int y=brickimg.getBottom()-brickimg.getTop();
   final TranslateAnimation translate = new TranslateAnimation(
           Animation.ABSOLUTE,x1, Animation.ABSOLUTE,
           -4000, Animation.ABSOLUTE,0,
           Animation.ABSOLUTE,y);//How far it goes on the axis. The first x goes left, second x goes right, first y goes up, second goes down
   translate.setDuration(1200);//speed of the animation
   translate.setFillEnabled(true);
   translate.setFillAfter(true);