Permissions, Performance & Security in Android



Permissions, Performance & Security in Android

Permissions, Performance & Security in Android

Permissions in Android

Permissions are used to protect user data and system features.

Types of Permissions

TypeDescriptionExample
NormalLow riskInternet
DangerousNeeds user approvalCamera, Location
SignatureSame app signatureSystem apps

Declare Permission

<uses-permission android:name="android.permission.INTERNET"/>

Runtime Permission (Android 6+)

if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA}, 1);
}

Permission Flow

Request → User Prompt → Allow / Deny → App Action

Firebase

Backend-as-a-Service platform.

Services

ServiceUse
AuthenticationLogin system
FirestoreNoSQL DB
Realtime DBLive data
Cloud MessagingNotifications
AnalyticsApp tracking

Firebase Architecture

App → Firebase SDK → Cloud Services → Database/Analytics

AdMob (Google Ads)

Used to monetize apps by showing ads.

Ad Types

TypeDescription
BannerSmall ads
InterstitialFull screen
RewardedUser earns reward

Example

AdView adView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);

APK Signing 

Process of digitally signing APK before release.

Why Needed?

  • Ensures app authenticity
  • Required for Play Store

Signing Types

TypeUse
DebugTesting
ReleaseProduction

Signing Process

Code → Build APK → Sign with Key → Release APK

Packaging & Deployment

Steps

  1. Build APK / AAB
  2. Optimize app
  3. Test
  4. Deploy

Deployment Flow

Code → Build → Test → Upload → Publish

Publish App (Play Store)

Steps

  1. Create account on Google Play Console
  2. Upload APK/AAB
  3. Add app details
  4. Set pricing
  5. Publish

Requirements

  • Signed APK
  • Privacy policy
  • Screenshots

Google Maps

Used to display maps in apps.

Features

  • Markers
  • Location tracking
  • Navigation

Example

GoogleMap map;
map.addMarker(new MarkerOptions().position(new LatLng(28.6, 77.2)));

GPS & Wi-Fi Positioning

Location Sources

SourceAccuracyUse
GPSHighOutdoor
Wi-FiMediumIndoor
Mobile NetworkLowGeneral

Location Flow

GPS/Wi-Fi → Location Manager → App

Location Services

Example

FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient(this);

Permissions Required

  • ACCESS_FINE_LOCATION
  • ACCESS_COARSE_LOCATION

Download Manager

Handles long-running downloads.

Features

  • Runs in background
  • Retry support

Example

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

WorkManager

Used for deferrable background tasks.

Features

  • Guaranteed execution
  • Works even after restart

WorkManager Flow

WorkRequest → WorkManager → Background Execution

Example

WorkRequest work = new OneTimeWorkRequest.Builder(MyWorker.class).build();
WorkManager.getInstance(this).enqueue(work);

Alarms (AlarmManager)

Schedules tasks at specific time.

Example

AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);

Alarm Flow

Set Time → Alarm Trigger → BroadcastReceiver → Action

Sensors in Android

Types

SensorUse
AccelerometerMotion
GyroscopeRotation
ProximityDistance

Example

SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE);

Performance Optimization

Techniques

  • Use background threads
  • Optimize layouts
  • Reduce memory usage
  • Use caching

Performance Tips Table

TechniqueBenefit
Lazy loadingFaster UI
CachingReduce network
RecyclerViewEfficient UI

Security Best Practices

Techniques

  • Use HTTPS
  • Encrypt data
  • Secure APIs
  • Use ProGuard

Security Layers

User → App → Encryption → Secure Server

Important Exam Questions

Short Questions

  • What is APK signing?
  • Define WorkManager.
  • What is Firebase?

Long Questions

  • Explain permissions in Android.
  • Describe Google Maps integration.
  • Explain WorkManager vs AlarmManager.

Practical Questions

  • Request runtime permission.
  • Implement WorkManager.
  • Show map with marker.

Final Summary

  • Permissions → user security
  • Firebase → backend
  • AdMob → monetization
  • APK Signing → authenticity
  • WorkManager → background tasks
  • Google Maps → location features
  • Sensors → hardware interaction