ҚOCЫМШA А
Бағдарлама лиcтингi
package com.codingwithsara.notificationapp;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.core.app.NotificationCompat;
public class AlarmReceiver extends BroadcastReceiver {
private static final String CHANNEL_ID = "CHANNEL_SAMPLE";
@Override
public void onReceive(Context context, Intent intent) {
// Get id & message
int notificationId = intent.getIntExtra("notificationId", 0);
String message = intent.getStringExtra("message");
// Call MainActivity when notification is tapped.
Intent mainIntent = new Intent(context, MainActivityNavData.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, mainIntent, 0);
// NotificationManager
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// For API 26 and above
CharSequence channelName = "My Notification";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, channelName, importance);
notificationManager.createNotificationChannel(channel);
}
// Prepare Notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setContentTitle("TITLE")
.setContentText(message)
.setContentIntent(contentIntent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);
// Notify
notificationManager.notify(notificationId, builder.build());
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button buttonNext = (Button)findViewById (R.id.btn_1 );
buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivity.this, MainActivityVol.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityBask extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_baskl);
Button buttonNext = (Button)findViewById (R.id.btn_1 );
buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityBask.this, MainActivityMenu.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityFoot extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_foot);
Button buttonNext = (Button)findViewById (R.id.btn_1 );
buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityFoot.this, MainActivityTableT.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityMenu extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
ImageButton buttonNext = (ImageButton) findViewById(R.id.img_vol);
buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenu.this, MainActivityMenuVal.class);
startActivity(intent);
}catch(Exception e){
}
}
});
ImageButton buttonNextFoot = (ImageButton) findViewById(R.id.img_footb);
buttonNextFoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenu.this, MainActivityMenuFoot.class);
startActivity(intent);
}catch(Exception e){
}
}
});
ImageButton buttonNextTableT = (ImageButton) findViewById(R.id.img_t_ten);
buttonNextTableT.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenu.this, MainActivityMenuTableTen.class);
startActivity(intent);
}catch(Exception e){
}
}
});
ImageButton buttonNextBask = (ImageButton) findViewById(R.id.img_bask);
buttonNextBask.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenu.this, MainActivityMenuBask.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Button buttonNextData = (Button) findViewById(R.id.dadaNavBtn);
buttonNextData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenu.this, MainActivityNavData.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Button buttonschet = (Button) findViewById(R.id.schet1);
buttonschet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent san = new Intent(MainActivityMenu.this, MainSchet.class);
startActivity(san);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
/*public
void schet ( View view ) {
Intent intent=new Intent (MainActivityMenu.this, MainSchet.class);
startActivity ( intent );
}*/
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityMenuBask extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_bask);
Button buttonBack = (Button) findViewById(R.id.button_back);
buttonBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenuBask.this, com.codingwithsara.notificationapp.MainActivityMenu.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityMenuFoot extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_foot);
Button buttonBack = (Button) findViewById(R.id.button_back);
buttonBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenuFoot.this, com.codingwithsara.notificationapp.MainActivityMenu.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityMenuTableTen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_t_ten);
Button buttonBack = (Button) findViewById(R.id.button_back);
buttonBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenuTableTen.this, com.codingwithsara.notificationapp.MainActivityMenu.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityMenuVal extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_vol);
Button buttonBack = (Button) findViewById(R.id.button_back);
buttonBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityMenuVal.this, com.codingwithsara.notificationapp.MainActivityMenu.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TimePicker;
import android.widget.Toast;
import java.util.Calendar;
public class MainActivityNavData extends AppCompatActivity implements View.OnClickListener {
private int notificationId = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nav_main_data);
Button buttonBack = (Button) findViewById(R.id.button_back);
buttonBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityNavData.this, com.codingwithsara.notificationapp.MainActivityMenu.class);
startActivity(intent);
}catch(Exception e){
}
}
});
// Set onClick Listener
findViewById(R.id.setBtn).setOnClickListener(this);
findViewById(R.id.cancelBtn).setOnClickListener(this);
}
@Override
public void onClick(View view) {
EditText editText = findViewById(R.id.editText);
TimePicker timePicker = findViewById(R.id.timePicker);
// Intent
Intent intent = new Intent(MainActivityNavData.this, AlarmReceiver.class);
intent.putExtra("notificationId", notificationId);
intent.putExtra("message", editText.getText().toString());
// PendingIntent
PendingIntent pendingIntent = PendingIntent.getBroadcast(
MainActivityNavData.this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT
);
// AlarmManager
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
switch (view.getId()) {
case R.id.setBtn:
int hour = timePicker.getCurrentHour();
int minute = timePicker.getCurrentMinute();
// Create time.
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, hour);
startTime.set(Calendar.MINUTE, minute);
startTime.set(Calendar.SECOND, 0);
long alarmStartTime = startTime.getTimeInMillis();
// Set Alarm
alarmManager.set(AlarmManager.RTC_WAKEUP, alarmStartTime, pendingIntent);
Toast.makeText(this, "Done!", Toast.LENGTH_SHORT).show();
break;
case R.id.cancelBtn:
alarmManager.cancel(pendingIntent);
Toast.makeText(this, "Canceled.", Toast.LENGTH_SHORT).show();
break;
}
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityTableT extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_table_t);
Button buttonNext = (Button)findViewById (R.id.btn_1 );
buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityTableT.this, com.codingwithsara.notificationapp.MainActivityBask.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivityVol extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_vol);
Button buttonNext = (Button)findViewById (R.id.btn_1 );
buttonNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent(MainActivityVol.this, com.codingwithsara.notificationapp.MainActivityFoot.class);
startActivity(intent);
}catch(Exception e){
}
}
});
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
package com.codingwithsara.notificationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class MainSchet extends AppCompatActivity {
public int birinshi=0;
public int ekinshi=0;
public TextView textView6, textView7;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schet);
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Button button4 = (Button) findViewById(R.id.button4);
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
birinshi=birinshi+1;
textView6.setText ( birinshi );
}
});
Button button3 = (Button) findViewById(R.id.button3);
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ekinshi=ekinshi+1;
textView7.setText ( ekinshi );
}
});
Button button5 = (Button) findViewById(R.id.button5);
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ekinshi=0;
birinshi=0;
textView7.setText ( ekinshi );
textView6.setText ( birinshi );
}
});
}
Достарыңызбен бөлісу: |