Note that there are some explanatory texts on larger screens.

plurals
  1. POBroadcastReceiver declared in Android Manifest, App force closing.
    text
    copied!<p>I keep getting Force close error while testing this app. App opening fine.. but after 3-4 seconds force close error dialog box coming up. code included. Any help will be appreciated. Thanks</p> <p><strong>Manifest</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cy.headset" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;receiver android:name=".Main" &gt; &lt;intent-filter&gt; &lt;action android:name="android.content.Intent.ACTION_BATTERY_CHANGED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;activity android:name="com.cy.headset.Main" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; </code></pre> <p></p> <p><strong>Java Code</strong></p> <pre><code>package com.cy.headset; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class Main extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent i) { Toast.makeText(context, "Headphone connected", Toast.LENGTH_LONG).show(); }} </code></pre> <p><strong>XML UI file</strong></p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".Main" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_margin="10dp" android:layout_marginTop="151dp" android:text="@string/hello_world" android:textAlignment="center" /&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload