Hello,This is me!

Sanjay Yadav

Web Designer Android Developer Cloud Computing

About me

Hello

I'mSanjay Yadav

Bachelor of Technology and Master of Technology in Computer Science and Engineering

My career objective is to pursue a career as a computer engineer and contribute to the industry by utilising my knowledge, skills and expertise.I also worked as internet of things trainee under the manager of Allsoft-IBM department. Learned and performed on how to develop sms voting system using GSM.and I'm Enthusiast of Android Development

experience

Front-End Development

2012-2016

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the

UI/UX Design

2012-2016

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the

Website production

2012-2016

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the

Website maintain

2012-2016

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the

service

Easily Customised

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

MODERN DESIGN

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

User Friendly

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

RESPONSIVE DEVELOPMENT

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

USER EXPERIENCE

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Lovely Design

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

3000

LINES OF CODE

50

COFFEE CUPS

324

BOOKS

1234

GIFTS

Projects

Android Project to creates a Alarm clock

Creating a New project:


To Download the project click on  Download button:








  • Open Android Studio and then click on File -> New -> New project.
new project
  • Then type the Application name as “ex.no.11″ and click Next. 
application-name-11
  • Then select the Minimum SDK as shown below and click Next.
minimum sdk
  • Then select the Empty Activity and click Next. 
empty activity
  • Finally click Finish.
finish
  • It will take some time to build and load the project.
  • After completion it will look as given below.
new

Creating Second Activity for the Android Application:

  • Click on File -> New -> Activity -> Empty Activity.
New activity
  • Type the Activity Name as AlarmReceiver and click Finish button.
AlarmActivity
  • Thus Second Activity For the application is created.

Designing layout for the Android Application:

  • Click on app -> res -> layout -> activity_main.xml.
activity_main
  • Now click on Text as shown below.
text
  • Then delete the code which is there and type the code as given below

      Code for Activity_main.xml
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        <?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">
         
            <TimePicker
                android:id="@+id/timePicker"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center" />
         
            <ToggleButton
                android:id="@+id/toggleButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="20dp"
                android:checked="false"
                android:onClick="OnToggleClicked" />
         
        </LinearLayout>

  • Now click on Design and your application will look as given below.
design-11
  • So now the designing part is completed.

Changes in Manifest for the Android Application:

  • Click on app -> manifests -> AndroidManifest.xml
manifest-11-a
  • Now change the activity tag to receiver tag in the AndroidManifest.xml file as shown below
manifest-11

Code for AndroidManifest.xml:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.exno11" >
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity android:name=".MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name=".AlarmReceiver" >
        </receiver>
    </application>
</manifest>


  • So now the changes are done in the Manifest.

Java Coding for the Android Application:

Java Coding for Main Activity:

  • Click on app -> java -> com.example.exno11 -> MainActivity.
MainActivity

  • Then delete the code which is there and type the code as given below.
  • Code for MainActivity.java:

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    package com.example.exno11;
    import android.app.AlarmManager;
    import android.app.PendingIntent;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.TimePicker;
    import android.widget.Toast;
    import android.widget.ToggleButton;
    import java.util.Calendar;
    public class MainActivity extends AppCompatActivity
    {
        TimePicker alarmTimePicker;
        PendingIntent pendingIntent;
        AlarmManager alarmManager;
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            alarmTimePicker = (TimePicker) findViewById(R.id.timePicker);
            alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        }
        public void OnToggleClicked(View view)
        {
            long time;
            if (((ToggleButton) view).isChecked())
            {
                Toast.makeText(MainActivity.this, "ALARM ON", Toast.LENGTH_SHORT).show();
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.HOUR_OF_DAY, alarmTimePicker.getCurrentHour());
                calendar.set(Calendar.MINUTE, alarmTimePicker.getCurrentMinute());
                Intent intent = new Intent(this, AlarmReceiver.class);
                pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
                time=(calendar.getTimeInMillis()-(calendar.getTimeInMillis()%60000));
                if(System.currentTimeMillis()>time)
                {
                    if (calendar.AM_PM == 0)
                        time = time + (1000*60*60*12);
                    else
                        time = time + (1000*60*60*24);
                }
                alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, time, 10000, pendingIntent);
            }
            else
            {
                alarmManager.cancel(pendingIntent);
                Toast.makeText(MainActivity.this, "ALARM OFF", Toast.LENGTH_SHORT).show();
            }
        }
    }

  • So now the Coding part of Main Activity is completed.

Java Coding for Alarm Receiver:

  • Click on app -> java -> com.example.exno11 -> AlarmReceiver.
AlarmActivity-java
  • Then delete the code which is there and type the code as given below.
Code for AlarmReceiver.java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.example.exno11;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.widget.Toast;
public class AlarmReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        Toast.makeText(context, "Alarm! Wake up! Wake up!", Toast.LENGTH_LONG).show();
        Uri alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        if (alarmUri == null)
        {
            alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        }
        Ringtone ringtone = RingtoneManager.getRingtone(context, alarmUri);
        ringtone.play();
    }
}

  • So now the Coding part of Alarm Receiver is also completed.
  • Now run the application to see the output.

Output:

android application      
      

Result:

              Thus Android Application that creates Alarm Clock is developed and executed successfully.










testimonial

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Larry Page

CEO of Google

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Steve Jobs

CEO of apple

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Mark Zuckerberg

CEO of facebook

SANJAY YADAV
+123-456-789
Jalandhar, India

SEND ME A MESSAGE

Search This Blog

Powered by Blogger.

Blog Archive

Android Project to creates a Alarm clock

Creating a New project: To Download the project click on  Download button: Open Android Studio and then ...