SlideShare a Scribd company logo
1 of 3
Xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btn1"
android:layout_width="166dp"
android:layout_height="84dp"
android:text="Start "
android:onClick="startservic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.317" />
<Button
android:id="@+id/btn2"
android:layout_width="182dp"
android:layout_height="76dp"
android:text="Stop"
android:onClick="stopservic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.667" />
</androidx.constraintlayout.widget.ConstraintLayout>
Menifist.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.spinneenew">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
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>
<service android:name=".Myservice"/>
</application>
</manifest>
Newjava Myservice
package com.example.spinneenew;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.provider.Settings;
import android.widget.Toast;
public class Myservice extends Service {
private MediaPlayer mp;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
mp=MediaPlayer.create(this, Settings.System.DEFAULT_RINGTONE_URI);
mp.setLooping(false);
mp.start();
Toast.makeText(this,"Service is started",Toast.LENGTH_LONG).show();
return START_STICKY;
}
@Override
public void onCreate() {
Toast.makeText(this,"Service is created",Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this,"Service is destroy",Toast.LENGTH_LONG).show();
}
}
main.java
package com.example.spinneenew;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.Manifest;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void startservic(View v)
{
Intent intent=new Intent(this,Myservice.class);
startservic(intent);
}
public void stopservic(View v) {
stopservic(new Intent(this, Myservice.class));
}
}

More Related Content

What's hot

Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
Mohammad Shaker
 
Android Layout 3分クッキング
Android Layout 3分クッキングAndroid Layout 3分クッキング
Android Layout 3分クッキング
Yuki Anzai
 
Making The Most Of Mobile
Making The Most Of MobileMaking The Most Of Mobile
Making The Most Of Mobile
Suzzicks
 
Cross browser testing
Cross browser testingCross browser testing
Cross browser testing
aralikatte
 
アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼
アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼ アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼
アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼
Yuki Anzai
 

What's hot (20)

Presentation on Ember.js
Presentation on Ember.js Presentation on Ember.js
Presentation on Ember.js
 
4.preference management
4.preference management 4.preference management
4.preference management
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
 
Android Layout 3分クッキング
Android Layout 3分クッキングAndroid Layout 3分クッキング
Android Layout 3分クッキング
 
Ionic by Example
Ionic by ExampleIonic by Example
Ionic by Example
 
Making The Most Of Mobile
Making The Most Of MobileMaking The Most Of Mobile
Making The Most Of Mobile
 
Cross browser testing
Cross browser testingCross browser testing
Cross browser testing
 
アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼
アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼ アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼
アプリのUIを改善するための7ステップ ∼Bump Recorder の UI を設計してみたよ編∼
 
Building Drupal Apps for Distributions
Building Drupal Apps for DistributionsBuilding Drupal Apps for Distributions
Building Drupal Apps for Distributions
 
V Legakis Presentation
V Legakis PresentationV Legakis Presentation
V Legakis Presentation
 
I/O Rewind 215: What's new in Android
I/O Rewind 215: What's new in AndroidI/O Rewind 215: What's new in Android
I/O Rewind 215: What's new in Android
 
Support Design Library
Support Design LibrarySupport Design Library
Support Design Library
 
Droidcon Moscow 2015. Support Design Library. Григорий Джанелидзе - e-Legion
Droidcon Moscow 2015. Support Design Library. Григорий Джанелидзе - e-LegionDroidcon Moscow 2015. Support Design Library. Григорий Джанелидзе - e-Legion
Droidcon Moscow 2015. Support Design Library. Григорий Джанелидзе - e-Legion
 
Creating Yahoo Mobile Widgets
Creating Yahoo Mobile WidgetsCreating Yahoo Mobile Widgets
Creating Yahoo Mobile Widgets
 
Facebook과 연동하기
Facebook과 연동하기Facebook과 연동하기
Facebook과 연동하기
 
Responsive design
Responsive designResponsive design
Responsive design
 
Páginas Dinâmicas de Erro em Rails com Goalie
Páginas Dinâmicas de Erro em Rails com GoaliePáginas Dinâmicas de Erro em Rails com Goalie
Páginas Dinâmicas de Erro em Rails com Goalie
 
Testing For Web Accessibility
Testing For Web AccessibilityTesting For Web Accessibility
Testing For Web Accessibility
 
Jager
JagerJager
Jager
 

Similar to Services

android layouts
android layoutsandroid layouts
android layouts
Deepa Rani
 

Similar to Services (20)

Chapter 5 - Layouts
Chapter 5 - LayoutsChapter 5 - Layouts
Chapter 5 - Layouts
 
Android LAb - Creating an android app with Radio button
Android LAb - Creating an android app with Radio buttonAndroid LAb - Creating an android app with Radio button
Android LAb - Creating an android app with Radio button
 
Android Layout
Android LayoutAndroid Layout
Android Layout
 
1. shared pref
1. shared pref1. shared pref
1. shared pref
 
Practical 14 android.docx
Practical 14 android.docxPractical 14 android.docx
Practical 14 android.docx
 
Android Button
Android ButtonAndroid Button
Android Button
 
Creation of simple application using - step by step
Creation of simple application using - step by stepCreation of simple application using - step by step
Creation of simple application using - step by step
 
Ch2 first app
Ch2 first appCh2 first app
Ch2 first app
 
Advance Android application development workshop day 2
Advance Android application development workshop day 2Advance Android application development workshop day 2
Advance Android application development workshop day 2
 
Make your app dance with MotionLayout
Make your app dance with MotionLayoutMake your app dance with MotionLayout
Make your app dance with MotionLayout
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android project
 
Material design basics
Material design basicsMaterial design basics
Material design basics
 
Layout
LayoutLayout
Layout
 
android layouts
android layoutsandroid layouts
android layouts
 
2. xamarin.android 2.2 hello xamarin android 구조 2.2.6 simple intent example(웹...
2. xamarin.android 2.2 hello xamarin android 구조 2.2.6 simple intent example(웹...2. xamarin.android 2.2 hello xamarin android 구조 2.2.6 simple intent example(웹...
2. xamarin.android 2.2 hello xamarin android 구조 2.2.6 simple intent example(웹...
 
Advanced Android gReporter
Advanced Android gReporterAdvanced Android gReporter
Advanced Android gReporter
 

More from university of Gujrat, pakistan

More from university of Gujrat, pakistan (20)

Change management
Change management Change management
Change management
 
Latest Trends in Digital Marketing
Latest Trends in Digital MarketingLatest Trends in Digital Marketing
Latest Trends in Digital Marketing
 
Dark web (2)
Dark web (2)Dark web (2)
Dark web (2)
 
Code of ethics and professional conduct (1)
Code of ethics and professional conduct (1)Code of ethics and professional conduct (1)
Code of ethics and professional conduct (1)
 
Certification accreditation and licensure (1)
Certification accreditation and licensure (1)Certification accreditation and licensure (1)
Certification accreditation and licensure (1)
 
biggest technology trends
biggest technology trendsbiggest technology trends
biggest technology trends
 
Freedom of information (1)
Freedom of information (1)Freedom of information (1)
Freedom of information (1)
 
Individual cognition ppt (1)
Individual cognition ppt (1)Individual cognition ppt (1)
Individual cognition ppt (1)
 
Top 10 highest (1)
Top 10 highest (1)Top 10 highest (1)
Top 10 highest (1)
 
creativity and imagination
creativity and imagination creativity and imagination
creativity and imagination
 
Brainstorming 078 (1)
Brainstorming 078 (1)Brainstorming 078 (1)
Brainstorming 078 (1)
 
speeh-artificial intelligemce
speeh-artificial intelligemce speeh-artificial intelligemce
speeh-artificial intelligemce
 
Pp dealing with problem complexity (1)
Pp dealing with problem complexity (1)Pp dealing with problem complexity (1)
Pp dealing with problem complexity (1)
 
Motivation
MotivationMotivation
Motivation
 
Vision of artificial intelligence (1)
Vision of artificial intelligence (1)Vision of artificial intelligence (1)
Vision of artificial intelligence (1)
 
Entrepreneurship (1)
Entrepreneurship (1)Entrepreneurship (1)
Entrepreneurship (1)
 
Role of professional societies
Role of professional societiesRole of professional societies
Role of professional societies
 
Dealing with culticultural environment (1)
Dealing with culticultural environment (1)Dealing with culticultural environment (1)
Dealing with culticultural environment (1)
 
Dealing with problem complexity (1)
Dealing with problem complexity (1)Dealing with problem complexity (1)
Dealing with problem complexity (1)
 
cyber security and cyber crime
cyber security and cyber crime cyber security and cyber crime
cyber security and cyber crime
 

Recently uploaded

Recently uploaded (20)

What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration Tooling
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 

Services