AIDE Tutorial - 35 Ringer Mode Changer
Watch the video and codes are below the video.
MainActivity.Java
package com.kcgroup.RMC;
Watch the video and codes are below the video.
MainActivity.Java
package com.kcgroup.RMC;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.media.*;
import android.content.*;
import android.view.View.*;
import android.view.*;
public class MainActivity extends Activity
{
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView text=(TextView)findViewById(R.id.mainTextView);
Button Sound =(Button)findViewById(R.id.mainButton);
Button Vibrate =(Button)findViewById(R.id.mainButton1);
Button silent =(Button)findViewById(R.id.mainButton2);
final AudioManager mode=(AudioManager)this
.getSystemService(Context.AUDIO_SERVICE);
Sound.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
text.setText("Mobile is in Sound Mode");
mode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
}
});
Vibrate.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
text.setText("Mobile is in Vibrate Mode");
mode.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
}
});
silent.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
text.setText("Mobile is in Silent Mode");
mode.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
});
}
}
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/mainTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="Activate Sound Mode" android:id="@+id/mainButton" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="Activate Vibrate Mode" android:id="@+id/mainButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="Activate Silent Mode" android:id="@+id/mainButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
0 comments:
Post a Comment