Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: How to start an Activity via button?
    text
    copied!<p>Noob Android developer here I'm more graphics than code but thought I'd start doing more coding. Anyway, I have some buttons on my main activity page and I want it so when the button is clicked it opens another class/activity. I've tried all the methods I've looked up and something is still not working, when I click the button in the emulator it just doesn't do anything, does't forcestop or anything just nothing, someone point me in the right direction please.</p> <p>Code from the main page where the button lives:</p> <pre><code>public class StartingPoint extends Activity { protected void onCreate(Bundle aim) { super.onCreate(aim); setContentView(R.layout.main); final Button bSL = (Button) findViewById(R.id.bSongList); bSL.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent SongList = new Intent(StartingPoint.this, SongList.class); StartingPoint.this.startActivity(SongList); } }); } } </code></pre> <p>Manifest</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="myname.appname" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar" &gt; &lt;activity android:name=".Splash" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" &gt; &lt;intent-filter&gt; &lt;action android:name="myname.appname.SPLASH" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".StartingPoint" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="myname.appname.STARTINGPOINT" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".SongList" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="myname.appname.SONGLIST" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>-L</p> <pre><code>Last 3 lines of logcat just after clicking the button in question. 01-02 21:59:50.473: I/ActivityManager(75): Starting: Intent { cmp=myname.appname/.SongList } from pid 681 01-02 21:59:52.953: I/ActivityManager(75): Displayed myname.appname/.SongList: +2s351ms 01-02 21:59:58.565: D/dalvikvm(348): GC_EXPLICIT freed 8K, 55% free 2591K/5703K, external 1625K/2137K, paused 520ms </code></pre>
 

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