HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN ANDROID CREATED BY NAVEENRAJU
Displaying an image and Playing an Audio File around 20 seconds.
After 20 seconds current Page is Redirected to AnotherPage.
from redirected page again going back to current page.
Code For above videos:
activity_main.xml:
<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=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="108dp"
android:text="@string/hello_world" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="@drawable/myicon" />
</RelativeLayout>
GUI Layout:
MainActivity.java:
package com.example.photoaudiodemo;
//import com.example.app1.Naveen;
//import com.example.app1.R;
import android.R.raw;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
MediaPlayer play;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
play = MediaPlayer.create(MainActivity.this, R.raw.entu);
play.start();
Thread td=new Thread()
{
public void run()
{
try
{
sleep(20000);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
finally{
Intent i =new Intent(MainActivity.this,Push.class);
startActivity(i);
}
}
};
td.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
play.release();
}
}
push.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Button02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Back" />
<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ActivityClass" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PhotoActionClass" />
</LinearLayout>
GraphicalLayOut:
Push.java
package com.example.photoaudiodemo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Push extends Activity{
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.push);
b1=(Button) findViewById(R.id.Button02);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i1 = new Intent(Push.this,MainActivity.class);
startActivity(i1);
}
});
}
}
No comments:
Post a Comment