Файл: 2. Разработка Программного продукта. 1 Концепция приложения.docx

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 05.12.2023

Просмотров: 64

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

(Профессиональное программирование)

    1. Дэрси Л. Разработка приложений для Android-устройств. Базовые принципы /Л. Дэрси, Ш. Кондер – Том 1. – Москва: Эксмо, 2014. – 598 с.

    2. Жвалевскийм А. Смартфоны Android без напряга. Руководство пользователя / . - СПб.: Санкт-Петербург, 2012. - 224 с.

    3. Колисниченко Д. Программирование для Android. Самоучитель /. - СПб.: Санкт-Петербург, 2013. - 736 с.

    4. Медникс З.. Программирование под Android. Издательство Питер, 2012. – 496

    5. Программирование для Android. Самоучитель / Денис Колиснеченко

. - СПб.: Санкт-Петербург, 2013. - 272 с.

    1. Рето Маейр /Android 2: программирование приложений для планшетных компьютеров и смартфонов : [пер. с англ. ] /. — М. : эскмо, 2013. 672 с. (Мировой компьютерный бестселлер).

    2. Харди Б., Филлипс Б. Программирование под Android.– Спб: Питер, 2013. – 592с.

    3. Бурнет Э. Привет, Android! Разработка мобильных приложений СПб.: Питер, 2012.

    4. Android [Электронный ресурс]. – Режим доступа: http://www.android.com/

    5. Android Studio [Электронный ресурс] - https://developer.android.com/studio/index.html

    6. Habrahabr.ru [Электронный ресурс]. – Режим доступа: https://habrahabr.ru/posts/programming/

    7. Java Учебник для начинающих программистов [Электронный ресурс] http://proglang.su/java

    8. Oracle [Электронный ресурс]. - https://www.oracle.com/index.html 19.Start Android учебник по Android для начинающих и продвинутых

[Электронный ресурс]. – Режим доступа: http://startandroid.ru/ru/ 20.Блог разработчиков Android [Электронный ресурс] - https://android-

developers.googleblog.com/2014/07/learn-to-think-like-android- developer.html

  1. Книги по Java [Электронный ресурс] - https://lyapidov.ru/category/programming/java/

  2. Компоненты приложения [Электронный ресурс] - https://developer.android.com/guide/components/activities/index.html#Li fecycle

  3. Мобильное приложение, что такое, определение, новости, статьи, видео [Электронный ресурс]. https://indicator.ru/tags/ mobilnoe- prilozhenie/

  4. Основные этапы разработки мобильных приложений [Электронный ресурс] – Режим доступа: https://spark.ru/startup/componentix/blog/4499/ osnovnie-etapi- razrabotki-mobilnih-prilozhenij

  5. Официальная документация по Android [Электронный ресурс]. - https://developer.android.com/guide/

  6. Приложение Google I / O 2017 для Android [Электронный ресурс] - https://github.com/google/iosched

  7. Программирование для android, java [Электронный ресурс] http://davidmd.ru/%D1%83%D1%80%D0%BE%D0%BA%D0%B8-


%D0%BF%D0%BE-android/

  1. Программирование на Java [Электронный ресурс] - http://study- java.ru/category/uroki-java/

  2. Руководство разработчика [Электронный ресурс] - http://mybiblioteka.su/tom3/7-59852.html

  3. Русская документация Android [Электронный ресурс] - http://easyandroid.ru/index.php?p=721

  4. Тестирование android приложений с помощью реальных устройств [Электронный ресурс] - http://www.fandroid.info/testirovanie-android- prilozhenij-s-pomoshhyu-realnyh-ustrojstv/

  5. Уроки по Java [Электронный ресурс] - https://javarush.ru/

  6. Уроки программирования [Электронный ресурс] - http://learn- android.ru/index.html

  7. Уроки программирования от Google [Электронный ресурс] - https://developer.android.com/training/index.html

  8. Приложение для мониторинга несанкционированных свалок



Приложение 1

Скрипт Базы Данных


USE [VideoSilencs]

GO
SET ANSI_NULLS ON

GO
SET QUOTED_IDENTIFIER ON

GO
CREATE TABLE [dbo].[Apartment](

[ID] [int] NOT NULL,

[Titles] [nvarchar](500) NULL,

[Descriptions] [nvarchar](500) NULL,

[Proce] [int] NULL,

[Photo] [nvarchar](500) NULL,


CREATE TABLE [dbo].[Owner](

[ID] [int] NOT NULL,

[FullName] [nvarchar](100) NOT NULL,

[Series] [int] NULL,

[Room] [int] NULL,

[Address] [nvarchar](100) NULL,

[Phone] [varchar](50) NULL,

[Email] [nvarchar](100) NOT NULL,

[DataBirth] [datetime] NULL,

[IssuedBy] [nvarchar](100) NULL,

[DataIssue] [datetime] NULL,

[DataRegistr] [datetime] NULL,

CONSTRAINT [PK_Owner] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO
CREATE TABLE [dbo].[Microdistrict](

[ID] [int] NOT NULL,

[Microdistrict] [nvarchar](50) NULL,

[IDCity] [int] NULL,

CONSTRAINT [PK_Microdistrict] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO
CREATE TABLE [dbo].[City](

[ID] [int] NOT NULL,

[CityNames] [nvarchar](50) NOT NULL,

CONSTRAINT [PK_City] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO
CREATE TABLE [dbo].[Employee](

[ID] [int] NOT NULL,

[FullName] [nvarchar](100) NULL,

[Position] [nvarchar](50) NULL,

CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO
CREATE TABLE [dbo].[Contract](

[ID] [int] NOT NULL,

[Data] [datetime] NULL,

[IDEmployee] [int] NULL,

[IDClient] [int] NULL,

[AddInformation] [nvarchar](100) NULL,

CONSTRAINT [PK_Contract_1] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO
CREATE TABLE [dbo].[Client](

[ID] [int] NOT NULL,

[FullName] [nvarchar](50) NOT NULL,

[Series] [int] NULL,

[Number] [int] NULL,

[Address] [nvarchar](100) NOT NULL,

[DataRegistr] [datetime] NULL,

[Phone] [int] NULL,

[Email] [nvarchar](100) NOT NULL,

[DataBirth] [datetime] NULL,

[IssuedBy] [nvarchar](100) NULL,

[DataIssue] [datetime] NULL,

CONSTRAINT [PK_Client] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Contract] WITH CHECK ADD CONSTRAINT [FK_Contract_Client1] FOREIGN KEY([IDClient])

REFERENCES [dbo].[Client] ([ID])

GO
ALTER TABLE [dbo].[Contract] CHECK CONSTRAINT [FK_Contract_Client1]

GO
ALTER TABLE [dbo].[Contract] WITH CHECK ADD CONSTRAINT [FK_Contract_Employee] FOREIGN KEY([IDEmployee])

REFERENCES [dbo].[Employee] ([ID])

GO
ALTER TABLE [dbo].[Contract] CHECK CONSTRAINT [FK_Contract_Employee]

GO
ALTER TABLE [dbo].[Microdistrict] WITH CHECK ADD CONSTRAINT [FK_Microdistrict_City1] FOREIGN KEY([IDCity])

REFERENCES [dbo].[City] ([ID])

GO
ALTER TABLE [dbo].[Microdistrict] CHECK CONSTRAINT [FK_Microdistrict_City1]

GO
ALTER TABLE [dbo].[Apartment] WITH CHECK ADD CONSTRAINT [FK_Apartment_Contract] FOREIGN KEY([IDContract])


REFERENCES [dbo].[Contract] ([ID])

GO

ALTER TABLE [dbo].[Apartment] WITH CHECK ADD CONSTRAINT [FK_Apartment_Owner] FOREIGN KEY([IDOwner])

REFERENCES [dbo].[Owner] ([ID])

GO
ALTER TABLE [dbo].[Apartment] CHECK CONSTRAINT [FK_Apartment_Owner]

GO

Приложение 2

Листинг программы


ublic class DemoActivity extends Activity {

public static final String EXTRA_MESSAGE = "message";

public static final String PROPERTY_REG_ID = "registration_id";

private static final String PROPERTY_APP_VERSION = "appVersion";

private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;

/**

* Substitute you own sender ID here. This is the project number you got

* from the API Console, as described in "Getting Started."

*/

String SENDER_ID = "887029561167";

/**

* Tag used on log messages.

*/

static final String TAG = "GCM Demo";

TextView mDisplay;

GoogleCloudMessaging gcm;

AtomicInteger msgId = new AtomicInteger();

Context context;

String regid;

private ArrayAdapter mNotificationAdapter;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

mDisplay = (TextView) findViewById(R.id.display);

context = getApplicationContext();

// Check device for Play Services APK. If check succeeds, proceed with GCM registration.

if (checkPlayServices()) {

gcm = GoogleCloudMessaging.getInstance(this);

regid = getRegistrationId(context);

if (regid.isEmpty()) {

registerInBackground();

}

} else {

Log.i(TAG, "No valid Google Play Services APK found.");

}

List
persons = Person.listAll(Person.class);

ArrayList notifications= new ArrayList<>();

// Copied

for (int i = persons.size()-1; i >= 0; --i){

notifications.add(persons.get(i).name+" detected on "+persons.get(i).time);

}

/*String [] notificationArray = {

"This ", "is", "a", "Dynamic", "List", "to", "display", "notifications",

"for", "the", " Application"

};

List notifications= new ArrayList(

Arrays.asList(notificationArray));*/

mNotificationAdapter= new ArrayAdapter(

this,

R.layout.list_item_notifications,

R.id.list_item_notifications_textview,

notifications

);

ListView listView= (ListView) findViewById(R.id.listview_notifications);

listView.setAdapter(mNotificationAdapter);

}

@Override

protected void onResume() {

super.onResume();

// Check device for Play Services APK.

checkPlayServices();

}

/**

* Check the device to make sure it has the Google Play Services APK. If

* it doesn't, display a dialog that allows users to download the APK from

* the Google Play Store or enable it in the device's system settings.

*/

private boolean checkPlayServices() {

int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

if (resultCode != ConnectionResult.SUCCESS) {

if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {

GooglePlayServicesUtil.getErrorDialog(resultCode, this,

PLAY_SERVICES_RESOLUTION_REQUEST).show();

} else {

Log.i(TAG, "This device is not supported.");

finish();

}

return false;

}

return true;

}

/**

* Stores the registration ID and the app versionCode in the application's

* {@code SharedPreferences}.

*

* @param context application's context.

* @param regId registration ID

g */

private void storeRegistrationId(Context context, String regId) {

final SharedPreferences prefs = getGcmPreferences(context);

int appVersion = getAppVersion(context);

Log.i(TAG, "Saving regId on app version " + appVersion);

SharedPreferences.Editor editor = prefs.edit();

editor.putString(PROPERTY_REG_ID, regId);

editor.putInt(PROPERTY_APP_VERSION, appVersion);

editor.commit();

}

/**

* Gets the current registration ID for application on GCM service, if there is one.

*


* If result is empty, the app needs to register.

*

* @return registration ID, or empty string if there is no existing

* registration ID.

*/

private String getRegistrationId(Context context) {

final SharedPreferences prefs = getGcmPreferences(context);

String registrationId = prefs.getString(PROPERTY_REG_ID, "");

if (registrationId.isEmpty()) {

Log.i(TAG, "Registration not found.");

return "";

}

// Check if app was updated; if so, it must clear the registration ID

// since the existing regID is not guaranteed to work with the new

// app version.

int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);

int currentVersion = getAppVersion(context);

if (registeredVersion != currentVersion) {

Log.i(TAG, "App version changed.");

return "";

}

return registrationId;

}

/**

* Registers the application with GCM servers asynchronously.

*


* Stores the registration ID and the app versionCode in the application's

* shared preferences.

*/

private void registerInBackground() {

new AsyncTask() {

@Override

protected String doInBackground(Void... params) {

String msg = "";

try {

if (gcm == null) {

gcm = GoogleCloudMessaging.getInstance(context);

}

regid = gcm.register(SENDER_ID);

msg = "Device registered, registration ID=" + regid;

// You should send the registration ID to your server over HTTP, so it

// can use GCM/HTTP or CCS to send messages to your app.

sendRegistrationIdToBackend();

// For this demo: we don't need to send it because the device will send

// upstream messages to a server that echo back the message using the

// 'from' address in the message.

// Persist the regID - no need to register again.

storeRegistrationId(context, regid);

} catch (IOException ex) {

msg = "Error :" + ex.getMessage();

// If there is an error, don't just keep trying to register.

// Require the user to click a button again, or perform

// exponential back-off.

}

return msg;

}

@Override

protected void onPostExecute(String msg) {

mDisplay.append(msg + "\n");

}

}.execute(null, null, null);

}

// Send an upstream message.

public void onClick(final View view) {

/*if (view == findViewById(R.id.send)) {

new AsyncTask() {

@Override

protected String doInBackground(Void... params) {

String msg = "";

try {

Bundle data = new Bundle();

data.putString("my_message", "Hello World");

data.putString("my_action", "com.google.android.gcm.demo.app.ECHO_NOW");

String id = Integer.toString(msgId.incrementAndGet());

gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data);

msg = "Sent message";

} catch (IOException ex) {

msg = "Error :" + ex.getMessage();

}

return msg;

}

@Override

protected void onPostExecute(String msg) {

Toast toast = new Toast(DemoActivity.this);

toast.makeText(DemoActivity.this, msg,Toast.LENGTH_SHORT).show();

}

}.execute(null, null, null);

} else*/

if (view == findViewById(R.id.clear)) {

mDisplay.setText("");

mNotificationAdapter.clear();

Person.deleteAll(Person.class);

Toast toast = new Toast(DemoActivity.this);

toast.makeText(DemoActivity.this,"Cleared All Items",Toast.LENGTH_SHORT).show();

}

}

@Override

protected void onDestroy() {

super.onDestroy();

}

/**

* @return Application's version code from the {@code PackageManager}.

*/

private static int getAppVersion(Context context) {

try {

PackageInfo packageInfo = context.getPackageManager()

.getPackageInfo(context.getPackageName(), 0);

return packageInfo.versionCode;

} catch (NameNotFoundException e) {

// should never happen

throw new RuntimeException("Could not get package name: " + e);

}

}

/**

* @return Application's {@code SharedPreferences}.

*/

private SharedPreferences getGcmPreferences(Context context) {

// This sample app persists the registration ID in shared preferences, but

// how you store the regID in your app is up to you.

return getSharedPreferences(DemoActivity.class.getSimpleName(),

Context.MODE_PRIVATE);

}

/**

* Sends the registration ID to your server over HTTP, so it can use GCM/HTTP or CCS to send

* messages to your app. Not needed for this demo since the device sends upstream messages

* to a server that echoes back the message using the 'from' address in the message.

*/

private void sendRegistrationIdToBackend() {

/* General Post

HttpURLConnection urlConnection = null;

try {

// Construct the URL for the OpenWeatherMap query

String urlStr = "http://videosurv-906.appspot.com/register";

Uri builtUri = Uri.parse(urlStr).buildUpon().build();

URL url = new URL(builtUri.toString());

urlConnection = (HttpURLConnection) url.openConnection();

urlConnection.setRequestMethod("POST");

urlConnection.setRequestProperty("id", regid);

urlConnection.connect();

Log.i("RegistrationIdToBackend", "Registered");

}catch (Exception e){

Log.e("RegistrationIdToBackend", "Error ", e);

}finally {

if (urlConnection != null) {

urlConnection.disconnect();

}

}

*/

String urlStr = "http://videosurv-906.appspot.com/register";

HttpClient client = new DefaultHttpClient();

HttpPost post = new HttpPost(urlStr);

List urlParameters = new ArrayList();

urlParameters.add(new BasicNameValuePair("id", regid));

try{

post.setEntity(new UrlEncodedFormEntity(urlParameters));

HttpResponse response = client.execute(post);

System.out.println("\nSending 'POST' request to URL : " + urlStr);

System.out.println("Post parameters : " + post.getEntity());

System.out.println("Response Code : " +

response.getStatusLine().getStatusCode());

}catch (Exception e){

Log.e("RegistrationIdToBackend","Error",e);

}

}

}

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

@Override

public void onReceive(Context context, Intent intent) {

// Explicitly specify that GcmIntentService will handle the intent.

ComponentName comp = new ComponentName(context.getPackageName(),

GcmIntentService.class.getName());

// Start the service, keeping the device awake while it is launching.

startWakefulService(context, (intent.setComponent(comp)));

setResultCode(Activity.RESULT_OK);

}

}

public class GcmIntentService extends IntentService {

public static final int NOTIFICATION_ID = 1;

private NotificationManager mNotificationManager;

NotificationCompat.Builder builder;

public GcmIntentService() {

super("GcmIntentService");

}

public static final String TAG = "GCM Video Surveillance";

@Override

protected void onHandleIntent(Intent intent) {

Bundle extras = intent.getExtras();

GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

// The getMessageType() intent parameter must be the intent you received

// in your BroadcastReceiver.

String messageType = gcm.getMessageType(intent);

if (!extras.isEmpty()) { // has effect of unparcelling Bundle

/*

* Filter messages based on message type. Since it is likely that GCM will be

* extended in the future with new message types, just ignore any message types you're

* not interested in, or that you don't recognize.

*/

if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {

sendNotification("Send error: " + extras.toString());

} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {

sendNotification("Deleted messages on server: " + extras.toString());

// If it's a regular GCM message, do some work.

} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

// This loop represents the service doing some work.

/* for (int i = 0; i < 5; i++) {

Log.i(TAG, "Working... " + (i + 1)

+ "/5 @ " + SystemClock.elapsedRealtime());

try {

Thread.sleep(5000);

} catch (InterruptedException e) {

}

}*/

Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());

// Post notification of received message.

sendNotification("Received: " + extras.getString("name"));

Log.i(TAG, "Received name : "+ extras.getString("name"));

// Adding time to the Notification

String time;

Calendar c= Calendar.getInstance();

SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEEE HH:mm:ss dd-MM-yyyy");

time= shortenedDateFormat.format(c.getTime());

Person person = new Person(extras.getString("name"), time);

person.save();

Log.i(TAG, "Received: " + extras.toString());

}

}

// Release the wake lock provided by the WakefulBroadcastReceiver.

GcmBroadcastReceiver.completeWakefulIntent(intent);

}

// Put the message into a notification and post it.

// This is just one simple example of what you might choose to do with

// a GCM message.

private void sendNotification(String msg) {

mNotificationManager = (NotificationManager)

this.getSystemService(Context.NOTIFICATION_SERVICE);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0,

new Intent(this, DemoActivity.class), 0);

NotificationCompat.Builder mBuilder =

new NotificationCompat.Builder(this)

.setSmallIcon(R.drawable.ic_stat_gcm)

.setContentTitle("GCM Notification")

.setStyle(new NotificationCompat.BigTextStyle()

.bigText(msg))

.setContentText(msg);

mBuilder.setContentIntent(contentIntent);

mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());

}

}