DevsOnFlutter / flutter_process_text

Flutter plugin to listen to the process text intent stream.
https://pub.dev/packages/flutter_process_text
BSD 3-Clause "New" or "Revised" License
14 stars 6 forks source link

Open app instead of showing toast #5

Closed arianneorpilla closed 3 years ago

arianneorpilla commented 3 years ago

This is almost what I need. I can't get the action_process_text package to work because I use my own method channels in my MainActivity, so if I use that I would get MissingPluginException and so on. This works, but it shows a toast instead of opening the app. Is there a way I can have the app open to a screen instead of showing a toast with this plugin?

divshekhar commented 3 years ago

Hello @lrorpilla, Thanks for posting an issue. The plugin sends a stream of data to the app when the app is in memory and when it is not, the app is opened. You just need to return false from the isAppRunning method in the MainActivity as directed in the docs and you will achieve what you want. Set showConfirmationToast to false in FlutterProcessText.initialize() (docs) and you will not get confirmation toast message.

Example:

public class MainActivity extends FlutterActivity {
   private static boolean isAppRunning;

   public static boolean getIsAppRunning() {
     return isAppRunning;
   }

   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
        isAppRunning = isAppRunning(this);
   }

    public static boolean isAppRunning(Context context) {
        return false;
    }
}
FlutterProcessText.initialize(
    showConfirmationToast: false,
    showRefreshToast: false,
    showErrorToast: true,
);

Hope this works!