Hello,

I used The Log.e and Log.d in many places in the code including in the
onCreate method and i found that the error is there and it's not going any
further beyond it...


Still don't know what's wrong though.

On Thu, Feb 23, 2012 at 11:40 PM, Mohamed Gougam <mblack...@gmail.com>wrote:

> Hello Moktarul, sorry for the late reply, i was playing around with the
> onCreate since you said you think that the source of the bug most probably
> is onCreate method, well i am putting the Logcat error messages and
> Activity code bellow,
>
> LogCat:
>
> 02-23 18:35:35.935: D/AndroidRuntime(228): Shutting down VM
> 02-23 18:35:35.946: W/dalvikvm(228): threadid=3: thread exiting with
> uncaught exception (group=0x4001b188)
> 02-23 18:35:35.946: E/AndroidRuntime(228): Uncaught handler: thread main
> exiting due to uncaught exception
> 02-23 18:35:35.985: E/AndroidRuntime(228): java.lang.RuntimeException:
> Unable to start activity
> ComponentInfo{android.mgo.helloandroid/android.mgo.helloandroid.BTDdetecetwithV7Activity}:
> java.lang.NullPointerException
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.ActivityThread.access$2200(ActivityThread.java:119)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.os.Looper.loop(Looper.java:123)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.ActivityThread.main(ActivityThread.java:4363)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> java.lang.reflect.Method.invokeNative(Native Method)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> java.lang.reflect.Method.invoke(Method.java:521)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> dalvik.system.NativeStart.main(Native Method)
> 02-23 18:35:35.985: E/AndroidRuntime(228): Caused by:
> java.lang.NullPointerException
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.mgo.helloandroid.BTDdetecetwithV7Activity.onCreate(BTDdetecetwithV7Activity.java:87)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
> 02-23 18:35:35.985: E/AndroidRuntime(228): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
> 02-23 18:35:35.985: E/AndroidRuntime(228): ... 11 more
> 02-23 18:35:36.015: I/dalvikvm(228): threadid=7: reacting to signal 3
> 02-23 18:35:36.065: I/dalvikvm(228): Wrote stack trace to
> '/data/anr/traces.txt'
>
>
> *The Activity:*
>
> package android.mgo.helloandroid;
>
> import java.util.Set;
>
> import android.app.Activity;
> import android.bluetooth.BluetoothAdapter;
> import android.bluetooth.BluetoothDevice;
> import android.content.BroadcastReceiver;
> import android.content.Context;
> import android.content.Intent;
> import android.content.IntentFilter;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.view.Window;
> import android.widget.ArrayAdapter;
> import android.widget.Button;
> import android.widget.ListView;
>
> public class BTDdetecetwithV7Activity extends Activity  {
>     /** Called when the activity is first created. */
>     // Debugging
>     private static final String TAG = "DeviceListActivity";
>     private static final boolean D = true;
>
>     // Return Intent extra
>     public static String EXTRA_DEVICE_ADDRESS = "device_address";
>
>     // Member fields
>     private BluetoothAdapter mBtAdapter;
>     private ArrayAdapter<String> mPairedDevicesArrayAdapter;
>     private ArrayAdapter<String> mNewDevicesArrayAdapter;
>
>       @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>
>         // Setup the window
>         requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
>         setContentView(R.layout.main);
>
>
>         // Set result CANCELED in case the user backs out
>         setResult(Activity.RESULT_CANCELED);
>
>         // Initialize the button to perform device discovery
>         Button scanButton = (Button) findViewById(R.id.button_scan);
>         scanButton.setOnClickListener(new OnClickListener() {
>             public void onClick(View v) {
>                 doDiscovery();
>                 v.setVisibility(View.GONE);
>             }
>         });
>
>         // Initialize array adapters. One for already paired devices and
>         // one for newly discovered devices
>         mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this,
> R.layout.main);
>         mNewDevicesArrayAdapter = new ArrayAdapter<String>(this,
> R.layout.main);
>
>         // Find and set up the ListView for paired devices
>         ListView pairedListView = (ListView)
> findViewById(R.id.paired_devices);
>         pairedListView.setAdapter(mPairedDevicesArrayAdapter);
>
>         // Find and set up the ListView for newly discovered devices
>         ListView newDevicesListView = (ListView)
> findViewById(R.id.new_devices);
>         newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
>
>
>         // Register for broadcasts when a device is discovered
>         IntentFilter filter = new
> IntentFilter(BluetoothDevice.ACTION_FOUND);
>         this.registerReceiver(mReceiver, filter);
>
>
>         // Register for broadcasts when discovery has finished
>         filter = new
> IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
>         this.registerReceiver(mReceiver, filter);
>
>         // Get the local Bluetooth adapter
>         mBtAdapter = BluetoothAdapter.getDefaultAdapter();
>
>
>         // Get a set of currently paired devices
>         Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
>
>
>         // If there are paired devices, add each one to the ArrayAdapter
>         if (pairedDevices.size() > 0) {
>
> findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
>
>             for (BluetoothDevice device : pairedDevices) {
>                 mPairedDevicesArrayAdapter.add(device.getName() + "\n" +
> device.getAddress());
>             }
>
>         } else {
>             String noDevices =
> getResources().getText(R.string.none_paired).toString();
>             mPairedDevicesArrayAdapter.add(noDevices);
>         }
>     }
>
>     @Override
>     protected void onDestroy() {
>         super.onDestroy();
>
>
>         // Make sure we're not doing discovery anymore
>         if (mBtAdapter != null) {
>             mBtAdapter.cancelDiscovery();
>         }
>
>
>         // Unregister broadcast listeners
>         this.unregisterReceiver(mReceiver);
>     }
>
>     /**
>      * Start device discover with the BluetoothAdapter
>      */
>     private void doDiscovery() {
>         if (D) Log.d(TAG, "doDiscovery()");
>
>
>         // Indicate scanning in the title
>         setProgressBarIndeterminateVisibility(true);
>         setTitle(R.string.scanning);
>
>
>         // Turn on sub-title for new devices
>         findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
>
>         // If we're already discovering, stop it
>         if (mBtAdapter.isDiscovering()) {
>             mBtAdapter.cancelDiscovery();
>         }
>
>
>
>         // Request discover from BluetoothAdapter
>         mBtAdapter.startDiscovery();
>
>     }
>         // The BroadcastReceiver that listens for discovered devices and
>         // changes the title when discovery is finished
>         private final BroadcastReceiver mReceiver = new
> BroadcastReceiver() {
>             @Override
>             public void onReceive(Context context, Intent intent) {
>                 String action = intent.getAction();
>
>
>
>             // When discovery finds a device
>             if (BluetoothDevice.ACTION_FOUND.equals(action)) {
>                 // Get the BluetoothDevice object from the Intent
>                 BluetoothDevice device =
> intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
>                 // If it's already paired, skip it, because it's been
> listed already
>                 if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
>                     mNewDevicesArrayAdapter.add(device.getName() + "\n" +
> device.getAddress());
>                 }
>
>             } else if
> (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
>                 setProgressBarIndeterminateVisibility(false);
>                 setTitle(R.string.select_device);
>                 if (mNewDevicesArrayAdapter.getCount() == 0) {
>                     String noDevices =
> getResources().getText(R.string.none_found).toString();
>                     mNewDevicesArrayAdapter.add(noDevices);
>                 }
>             }
>         }
>     };
>
> }
>
>
>
>
> On Thu, Feb 23, 2012 at 9:27 AM, moktarul anam <mokta...@gmail.com> wrote:
>
>> can u please send me ur activity code and little more log message
>>
>> Moktarul anam
>>
>> On Feb 23, 10:18 am, moktarul anam <mokta...@gmail.com> wrote:
>> > Hi Soyer,
>> >
>> > I think problem is in ur oncreate or onstart method.  can u please do
>> > that ...
>> > remove all code from oncreate and check
>> >
>> > Can u please send little more log
>> > Moktarul
>> >
>> > On Feb 22, 11:42 pm, Mohamed Gougam <mblack...@gmail.com> wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Hello moktarul, the thing about manifest.xml, is tht i have only one
>> > > activity so nothing to get confused with. the manifest file is bellow:
>> >
>> > > <?xml version="1.0" encoding="utf-8"?>
>> > > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>> > >     package="android.mgo.helloandroid"
>> > >     android:versionCode="1"
>> > >     android:versionName="1.0" >
>> >
>> > >     <uses-sdk android:minSdkVersion="7" />
>> >
>> > >     <application
>> > >         android:icon="@drawable/ic_launcher"
>> > >         android:label="@string/app_name" >
>> > >         <activity
>> > >             android:label="@string/app_name"
>> > >             android:name=".BTDdetecetwithV7Activity">
>> > >             <intent-filter>
>> > >                 <action android:name="android.intent.action.MAIN"/>
>> >
>> > >                 <category
>> android:name="android.intent.category.LAUNCHER"/>
>> > >             </intent-filter>
>> > >         </activity>
>> > >     </application>
>> > >             <uses-permission
>> android:name="android.permission.BLUETOOTH"/>
>> > >             <uses-permission
>> > > android:name="android.permission.BLUETOOTH_ADMIN"/>
>> > > </manifest>
>> >
>> > > On Wed, Feb 22, 2012 at 1:04 AM, Mohamed Gougam <mblack...@gmail.com>
>> wrote:
>> > > > Hello  moktarul,
>> >
>> > > > Thanks alot, i will do that, and let you know :)
>> >
>> > > > On Tue, Feb 21, 2012 at 12:10 PM, moktarul anam <mokta...@gmail.com
>> >wrote:
>> >
>> > > >> sorry, its Activity Intent filter not internt filter
>> > > >> Moktarul
>> >
>> > > >> On Feb 21, 12:42 pm, moktarul anam <mokta...@gmail.com> wrote:
>> > > >> > Hi Soyer,
>> > > >> > All your activity class has to be there in your Manifest.xml file
>> >
>> > > >> > if you call your activity class from other activity then that
>> class
>> > > >> > has to be main( internt filter main) Please check these two
>> point and
>> > > >> > i think this will solve ur problem.
>> > > >> > I am sure some problem in ur Manifest.xml file
>> >
>> > > >> > Moktarul
>> >
>> > > >> > On Feb 20, 11:24 pm, Mohamed Gougam <mblack...@gmail.com> wrote:
>> >
>> > > >> > > Hi Moktarul, What is in the the manifest file, you mean i have
>> to
>> > > >> remove
>> > > >> > > the "." ? i don't think that's it, the "." has to be there.
>> >
>> > > >> > > Thanks guys for the help, Kris is it wrong if somebody try to
>> learn
>> > > >> > > something different, out of his field !! Thanks for the help
>> though i
>> > > >> > > really appreciate it.
>> >
>> > > >> > > On Mon, Feb 20, 2012 at 3:44 PM, moktarul anam <
>> mokta...@gmail.com>
>> > > >> wrote:
>> > > >> > > > Hi
>> > > >> > > > BTDdetecetwithV7Activity in ur android  Manifest file
>> > > >> > > > <activity name="BTDdetecetwithV7Activity"/>\
>> >
>> > > >> > > > Enjoy
>> > > >> > > > moktarul
>> >
>> > > >> > > > On Feb 20, 12:26 am, Soyer <mblack...@gmail.com> wrote:
>> > > >> > > > > Hello everyone, Can anyone explain to me what this
>> following error
>> > > >> > > > > means? have anyone faced the same?
>> >
>> > > >> > > > > ERROR:
>> >
>> > > >> > > > > 02-19 18:10:41.321: E/AndroidRuntime(319):
>> > > >> java.lang.RuntimeException:
>> > > >> > > > > Unable to start activity
>> ComponentInfo{android.mgo.helloandroid/
>> > > >> > > > > android.mgo.helloandroid.BTDdetecetwithV7Activity}:
>> > > >> > > > > java.lang.NullPointerException
>> >
>> > > >> > > > --
>> > > >> > > > You received this message because you are subscribed to the
>> Google
>> > > >> > > > Groups "Android Developers" group.
>> > > >> > > > To post to this group, send email to
>> > > >> android-developers@googlegroups.com
>> > > >> > > > To unsubscribe from this group, send email to
>> > > >> > > > android-developers+unsubscr...@googlegroups.com
>> > > >> > > > For more options, visit this group at
>> > > >> > > >http://groups.google.com/group/android-developers?hl=en
>> >
>> > > >> --
>> > > >> You received this message because you are subscribed to the Google
>> > > >> Groups "Android Developers" group.
>> > > >> To post to this group, send email to
>> android-developers@googlegroups.com
>> > > >> To unsubscribe from this group, send email to
>> > > >> android-developers+unsubscr...@googlegroups.com
>> > > >> For more options, visit this group at
>> > > >>http://groups.google.com/group/android-developers?hl=en
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to