Android – Camera Preview

i’m trying the camera preview This is my code and it doesn’t throw any error, but the screen is still black. Any ideas? this.setContentView(R.layout.camerapreview); SurfaceView cameraSurface = (SurfaceView)findViewById(; SurfaceHolder holder = cameraSurface.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); =;;; camerapreview.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”” android:layout_width=”wrap_content” android:layout_height=”wrap_content”> <SurfaceView android:id=”@+id/cpPreview” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center”> </SurfaceView> </LinearLayout>

How to add spinner to subtitle – as in the Play Music app for Android?

Please refer to the attached image. setListNavigationCallbacks(mSpinnerAdapter, mNavigationCallback) adds a spinner pivoted under “My Library”, and I cannot add a sub-list under it. I am unable to find a method which adds a spinner for “ALL MUSIC”, not messing up with the main title of the action bar. Any help is appreciated !

Get row position in onCreateContextMenu

I’m trying to create a context menu that changes the available options depending on which row was clicked. But I can’t figure out how to get the row position in the listview for row that was clicked, until after the menu is created.

Can't add library to my android project

I’m creating a new app and I want to use some libraries like this: I had downloaded this library, added it to my workspace using New Android Project -> Create from existig source. Went to properties > android, and checked Is Library. Then I went to properties > android in my app project, and […]

IInAppBillingService.aidl cannot generate Java file in Android Studio

I am trying to use in app product purchase in Android App, I tried to put IInAppBillingService.aidl in many places but no one generates the Java file , here is my structure of App: Could someone help me to find where I am wrong ? Note: I am use using Android Studio.

How to check if the fragment exists?

I am trying to talk to the fragment from activity, but I am not sure if the fragment is visible or no. If the fragment does not exist, I cannot even do null check as it throws exception due to the casting. How do I check if the fragment exists? PlayerFragment = (PlayerFragment) mManager.findFragmentById(; playerFragment.onNotificationListener.updateUI();

Android V7 Support Library Popup Menu

I’m trying to implement a PopupMenu with the Support V7 Library. All compiles fine but when I try to call: PopupMenu popup = new PopupMenu(this, v); popup.getMenu().add(Menu.NONE,MENU_SHARE_A,1,R.string.A); popup.getMenu().add(Menu.NONE,MENU_SHARE_B,2,R.string.B);; an error occurs on call: 07-31 17:23:53.365: E/AndroidRuntime(14128): java.lang.RuntimeException: Binary XML file line #17: You must supply a layout_height attribute. Which refers I think to “abc_popup_menu_item_layout.xml” […]

Type mismatch: cannot convert from StringBuilder to String

This method returns the source of the given URL. private static String getUrlSource(String url) { try { URL localUrl = null; localUrl = new URL(url); URLConnection conn = localUrl.openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader(conn.getInputStream())); String line = “”; String html; StringBuilder ma = new StringBuilder(); while ((line = reader.readLine()) != null) { ma.append(line); […]

How can i send back data using finish?

Like i can send data from one activity to another using this: intent.putExtra(“Name”, Value); how can i send data when i am using finish() to get back to the previous activity. In my app from Activity_A i am going to Activity_B. In Activity_B i am marking a location on map, which gives me latitude and […]

android weightSum not working properly

I have a layout with three elements and its orientation is ‘horizontal’ I want to fix the size that each element occupy in my layout. first element should take 40% of the total space then second element should occupy 5% and third one should occupy remaining 55% space. My layout look like this: <LinearLayout xmlns:android=”” […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.