I am trying to start an activity when I connect the phone to the computer via usb, but not mount yet.
For this i used a broadcast reciever.
But Somehow the activity starts even without plugging in and it does not respond when I connect it to the computer.
Here is the code.
Please help..
Thanks
Using java Syntax Highlighting
- public class IntentReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- // TODO Auto-generated method stub
- Intent myStarterIntent = new Intent(context, tst.class);
- myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(myStarterIntent);
- }
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Using java Syntax Highlighting
- public class tst extends Activity{
- @Override
- public void onCreate(Bundle icicl){
- super.onCreate(icicl);
- setContentView(R.layout.main);
- }
- }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.intentReceiver" android:versionCode="1"
- android:versionName="1.0">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".tst" android:label="@string/app_name"
- android:icon="@drawable/icon">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <receiver android:name=".IntentReceiver" android:label="@string/app_name"
- android:icon="@drawable/icon">
- <intent-filter>
- <action android:name="android.intent.action.MEDIA_UNMOUNTED" />
- </intent-filter>
- </receiver>
- </application>
- <uses-sdk android:minSdkVersion="3" />
- </manifest>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4



