Android Messaging App Launchable Activity

82
April 09, 2017, at 09:26 AM

I am using an Android 6.0.1 device and need to be able to automate launching the Android native 'Messages' app, retrieve the number of message threads and then delete all threads. The problem I am having is that the launchable activity I am using for the apk opens up to the composition of a new message, and when I select the back arrow on the screen (to get to the screen I need to be at in order to do the required tasks), it closes the messaging app. It makes sense why the app closes when selecting that back arrow, since there was technically no previous screen in the trace. Any ideas how to work around this?

My code:

 subprocess.check_output(["adb", "shell", "am start -n com.android.mms/com.android.mms.ui.ConversationComposer"])
 element = WebDriverWait(self.driver, 10).until(
 EC.element_to_be_clickable((By.ID, "com.android.mms:id/actionbar_arrow")))
 element.click()

I have tried using other activities (appium lists a number of them), but nothing has given me desirable results.

The native Contact app on the other hand was easy to handle, since when using the launchable activity listed, it opens to the mainscreen:

    subprocess.check_output(["adb", "shell", "am start -n com.android.contacts/.activities.PeopleActivity"])
    element = WebDriverWait(self.driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//android.widget.Button[@text='More']")))
    element.click()
    element = WebDriverWait(self.driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//android.widget.TextView[@text='Delete']")))
    element.click()
    element = WebDriverWait(self.driver, 10).until(
    EC.element_to_be_clickable((By.ID, "com.android.contacts:id/select_all_checkbox")))
    element.click()
    contacts_on_device = self.driver.find_element_by_id("com.android.contacts:id/select_all_textview")
    contacts_on_device_text = contacts_on_device.text
    contacts_on_device_attribute_text = contacts_on_device.get_attribute('text')
    print contacts_on_device_attribute_text
    element = WebDriverWait(self.driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//android.widget.Button[@text='Delete']")))
    element.click()
    element = WebDriverWait(self.driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//android.widget.Button[@text='Delete']")))
    element.click()
READ ALSO
How to populate a ListView in Xamarin Android?

How to populate a ListView in Xamarin Android?

I have a Web Api that retrieves data from SQL databaseI need to consume web api in xamrin for android

85
routing traffic of any specific application on Android

routing traffic of any specific application on Android

I'm writing an app which tunnels the tcp and udp traffic of selected apps on unrooted devices

60
Custom android Cordova/PhoneGap keyboard

Custom android Cordova/PhoneGap keyboard

I have an android cordova app, that the client wants to display a custom keyboard for 1 input field in the appThis keyboard must consist of only the following characters

75
Duplicated ID in listview Android studio

Duplicated ID in listview Android studio

I'm learning about sqlite database and custom ArrayAdapterJust now i saw a problem - when i'm adding more then 6 items to db, whey started to duplicate each other

71