This document outlines key Android integration points for our AI assistant app, with detailed use cases and implementation considerations.
┌─────────────┐ ┌─────────────────┐ ┌───────────────┐
│ Assistant │ │ Intent │ │ Calendar App │
│ "Schedule │────►│ ACTION_INSERT │────►│ New Event │
│ meeting" │ │ EXTRA_EVENT │ │ Creation UI │
└─────────────┘ └─────────────────┘ └───────────────┘
- User Input: "Schedule a meeting with John tomorrow at 2pm about the project timeline"
- Assistant Action: Parses natural language for date, time, attendees, and subject
- Integration Method:
IntentwithCalendarContract.Events.CONTENT_URI - Data Passed:
Intent intent = new Intent(Intent.ACTION_INSERT) .setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startMillis) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endMillis) .putExtra(CalendarContract.Events.TITLE, "Project Timeline Discussion") .putExtra(CalendarContract.Events.DESCRIPTION, "Review current progress and next steps") .putExtra(Intent.EXTRA_EMAIL, "john@example.com");
- User Experience: Calendar app opens with pre-filled event details for confirmation
- Privacy Considerations: Access requires calendar permission grant
┌───────────────┐ ┌────────────────┐ ┌────────────┐
│ Assistant │ │ DocumentsProvider│ │ Spreadsheet│
│ "Update sales │────►│ com.google.sheets│───►│ Data │
│ spreadsheet" │ │ /sales_2023.xlsx │ │ │
└───────────────┘ └────────────────┘ └────────────┘
- User Input: "Add today's sales figures to our tracking spreadsheet: $5,200 for electronics and $3,800 for appliances"
- Assistant Action: Identifies target document, extracts data points, determines appropriate cells
- Integration Method:
DocumentsProviderorContentProviderdepending on app support - Implementation Details:
- Query document by name/path using
DocumentsContract - Open document as input stream
- Modify content (may require format-specific library)
- Save changes via output stream
- Query document by name/path using
- Error Handling: Provide feedback if document format is unsupported or data cannot be inserted correctly
- Advanced Feature: Maintain metadata about document structure for future edits
┌─────────────┐ ┌─────────────────┐ ┌───────────────┐
│ Assistant │ │ Intent │ │ Email/SMS App │
│ "Email John"│────►│ ACTION_SEND │────►│ Composer with │
│ │ │ EXTRA_TEXT │ │ Prefilled Text│
└─────────────┘ └─────────────────┘ └───────────────┘
- User Input: "Send an email to my team about the delayed shipment, explaining it will arrive next Tuesday"
- Assistant Action: Drafts appropriate email text, identifies team recipients
- Integration Methods:
- Simple: Intent with ACTION_SEND
- Gmail Specific: Gmail's ContentProvider (if available)
- Direct: JavaMail API with stored SMTP credentials (requires secure credential storage)
- Sample Code:
Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"team@company.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "Shipment Delay Notification"); intent.putExtra(Intent.EXTRA_TEXT, "Team,\n\nI wanted to inform you that our shipment has been delayed. It is now expected to arrive next Tuesday.\n\nBest regards,\nYour Name");
- Enhancement: Use contact groups to resolve "my team" to actual email addresses
┌─────────────┐ ┌─────────────────┐ ┌───────────────┐
│ Assistant │ │ Geofencing API │ │ BroadcastReceiver│
│ "Remind me │────►│ Location Trigger│────►│ Notification │
│ at grocery" │ │ │ │ When Arriving │
└─────────────┘ └─────────────────┘ └───────────────┘
- User Input: "Remind me to buy milk when I'm near Walmart"
- Assistant Action: Creates geofence around all nearby Walmart locations
- Integration Components:
- LocationManager + GeofencingClient: Set up proximity alert
- BroadcastReceiver: Handle geofence transitions
- NotificationManager: Display reminder when triggered
- Implementation Challenges:
- Power consumption balance with location accuracy
- Handling multiple possible locations (all Walmart stores)
- Reminder persistence across device reboots
- Sample Geofence Setup:
Geofence geofence = new Geofence.Builder() .setRequestId("walmart_reminder") .setCircularRegion(latitude, longitude, 500) // 500m radius .setExpirationDuration(Geofence.NEVER_EXPIRE) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER) .build();
- Privacy Considerations: Clear disclosure of background location usage
┌───────────────┐ ┌────────────────┐ ┌────────────┐
│ Assistant │ │ FileProvider │ │ Social App │
│ "Share this │────►│ content://... │────►│ Share UI │
│ chart" │ │ /temp_chart.png│ │ │
└───────────────┘ └────────────────┘ └────────────┘
- User Input: "Share this expense chart with my finance group on WhatsApp"
- Assistant Action: Generates visual representation of data, initiates share flow
- Integration Components:
- FileProvider: Secure file URI generation
- Intent.ACTION_SEND: Sharing mechanism
- Implementation Flow:
- Generate chart image (using chart library)
- Save to app's cache directory
- Get content:// URI via FileProvider
- Create share intent with specific target package (optional)
- Setup Requirements:
- FileProvider definition in AndroidManifest.xml
- XML paths file specifying shareable directories
- Sample Intent:
Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri); shareIntent.setType("image/png"); shareIntent.setPackage("com.whatsapp"); // Optional - target specific app
┌─────────────┐ ┌─────────────────┐ ┌───────────────┐
│ Assistant │ │ BroadcastReceiver│ │ Home App │
│ "Turn on │────►│ Custom Action │────►│ Device Control│
│ lights" │ │ │ │ API │
└─────────────┘ └─────────────────┘ └───────────────┘
- User Input: "Turn on the living room lights and set thermostat to 72 degrees"
- Assistant Action: Identifies devices, desired states, and sends commands
- Integration Options:
- Direct API Integration: Using smart home platform SDKs (Google Home, SmartThings, etc.)
- Intent-based: Launching companion apps with command parameters
- Custom Protocol: Broadcast intents for receiver apps
- Security Considerations:
- Authentication token management
- Permission model for critical home controls
- Activity logging for security-relevant actions
- Implementation Approach:
- Define standardized action schema for device operations
- Support device discovery and capability querying
- Implement state caching for faster response to queries
- Error Handling: Graceful degradation when devices are unreachable
┌───────────────┐ ┌────────────────┐ ┌────────────┐
│ Assistant │ │ ContentProvider│ │ Contacts │
│ "Add John's │────►│ contacts://... │────►│ Database │
│ new number" │ │ │ │ │
└───────────────┘ └────────────────┘ └────────────┘
- User Input: "Update Sarah Smith's contact with her new work email sarah.smith@newcompany.com"
- Assistant Action: Searches contacts, identifies correct entry, updates specific field
- Integration Method: ContactsContract ContentProvider
- Operation Flow:
- Query contacts to find matching name
- If multiple matches, use disambiguation (e.g., "Sarah Smith from Marketing")
- Update specific field (Email, Phone, etc.)
- Provide confirmation of change
- Sample Query:
Cursor cursor = contentResolver.query( ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.Contacts.DISPLAY_NAME + " = ?", new String[]{"Sarah Smith"}, null );
- Advanced Features:
- Contact relationship understanding ("my boss", "my sister")
- Contact merging suggestions
- Business context awareness ("Sarah from the meeting yesterday")
┌───────────────┐ ┌────────────────┐ ┌────────────┐
│ Assistant │ │ NotificationMgr│ │ Status Bar │
│ "Summarize │────►│ + Bundled │────►│ Grouped │
│ notifications"│ │ Notifications │ │ Summary │
└───────────────┘ └────────────────┘ └────────────┘
- User Input: "Read me my important notifications" or "What notifications did I miss?"
- Assistant Action: Accesses notification history, prioritizes, summarizes
- Integration Requirements:
NotificationListenerServiceimplementation- Special permission grant from user
- Careful notification categorization
- Implementation Considerations:
- Filter notifications by importance/category
- Apply NLP to extract key information
- Generate concise summaries grouping similar notifications
- Provide interaction options for each notification group
- Sample Service Declaration:
<service android:name=".NotificationListener" android:label="Assistant Notification Access" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service>
- Privacy Features:
- Content redaction options for sensitive apps
- User-configurable app exclusions
- Clear visual indicators when notification access is active
┌───────────────┐ ┌────────────────┐ ┌────────────┐
│ Assistant │ │ StorageAccessFw│ │ File System│
│ "Find my tax │────►│ DocumentsContract│───►│ Scoped │
│ documents" │ │ │ │ Access │
└───────────────┘ └────────────────┘ └────────────┘
- User Input: "Find my tax documents from last year"
- Assistant Action: Searches files using metadata and content patterns
- Integration Components:
- Storage Access Framework: For user-directed directory access
- MediaStore API: For media file access
- DocumentsContract: For general document queries
- Implementation Strategy:
- Build query based on file type, naming patterns, and creation dates
- Use content indexing for faster searches
- Maintain user's common document locations
- Advanced Features:
- Content-based search (documents containing certain text)
- OCR for document classification
- Document suggestion based on current date/context
- Learn from user interactions to improve future searches
┌───────────────┐ ┌────────────────┐ ┌────────────┐
│ Assistant │ │ Intent │ │ Settings │
│ "Turn on │────►│ ACTION_WIFI_ │────►│ Panel │
│ WiFi" │ │ SETTINGS │ │ │
└───────────────┘ └────────────────┘ └────────────┘
- User Input: "Turn on Do Not Disturb until my meeting ends at 3 PM"
- Assistant Action: Modifies system settings with time-based parameters
- Integration Methods:
- Settings.Global/System/Secure: For direct settings manipulation (requires permissions)
- Intent Actions: For launching specific settings panels
- Notification Policy Access: For DND control
- Implementation Permissions:
- WRITE_SETTINGS permission for some controls
- ACCESS_NOTIFICATION_POLICY for DND
- Time-based Management:
- Use AlarmManager for settings restoration
- Context-aware triggers (location, calendar events)
- Sample DND Code:
NotificationManager notificationManager = getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager.isNotificationPolicyAccessGranted()) { notificationManager.setInterruptionFilter( NotificationManager.INTERRUPTION_FILTER_PRIORITY); // Schedule end time AlarmManager alarmManager = getSystemService(AlarmManager.class); // Set alarm to disable DND at meeting end time }
- Clearly communicate permissions needed for each integration
- Provide granular control over which integrations are enabled
- Implement proper authentication for sensitive operations
- Maintain audit logs of system-modifying actions
- Minimize background processes for location monitoring
- Implement efficient ContentProvider queries
- Use batched operations when possible
- Consider battery impact of continuous monitoring
- Graceful degradation when services are unavailable
- Clear user communication about permission requirements
- Fallback options when primary integration paths fail
- Handle API variations across Android versions
- Maintain consistent interaction patterns across integrations
- Provide visual confirmation of system-changing actions
- Allow easy reversal of changes made by the assistant
- Use progressive disclosure for complex operations