samedi 9 mai 2015

android intent from other class in not working

I'm creating a intent in title_page_activity.java when i run this application the titlepage appears and the application stops unfortunately. and the DDMS says that the application doing more work on its main Thread. please help me with this

manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
    package="com.app.hems.cqu"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="22" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Title_page_activity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.app.hems.cqu.MAINACTIVITY" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>

mainpage.xml

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.app.hems.cqu.MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="78dp"
        android:text="@string/app_name"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@style/AppBaseTheme"
        android:textSize="80sp"
        android:textStyle="bold|italic" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/button1"
        android:layout_marginBottom="22dp"
        android:text="@string/contact"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:typeface="sans" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/signin"
        android:textStyle="bold" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/textView2"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="34dp"
        android:text="@string/signup"
        android:textStyle="bold" />

</RelativeLayout>


titlepage.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="@drawable/title_image"
    >

</RelativeLayout>

MainActivity.java

package com.app.hems.cqu;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle viewUserOptionPage) {
        super.onCreate(viewUserOptionPage);
        setContentView(R.layout.mainpage);
    }


}

Title_Page_Activity.java

package com.app.hems.cqu;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Title_page_activity extends Activity {

    @Override
    protected void onCreate(Bundle CreateTitleSleep) {
        // TODO Auto-generated method stub
        super.onCreate(CreateTitleSleep);
        setContentView(R.layout.titlepage);
        Thread Timer = new Thread(){
            public void run()
            {
                try
                {
                    sleep(2000);

                }
                catch(InterruptedException e)
                {
                    e.printStackTrace();
                }
                finally
                {
                    Intent openMainActivity = new Intent("com.app.hems.cqu.MAINACTIVITY");
                    startActivity(openMainActivity);
                }               
            }           
        };
        Timer.start();
        }

    }

Aucun commentaire:

Enregistrer un commentaire