Preventing a message from being sent in android - android

I know I can detect a message that is being sent using the following code
ContentResolver contentResolver = context.getContentResolver();
contentResolver.registerContentObserver(Uri.parse("content://sms"),true, myObserver);
what I need to know, is it possible to prevent it from going out or suspend it?
Thanks

Not possible unless you are the Messaging application that the user typed the message in to (then you could do whatever you want with it, including not send)
However if the user is using the stock Messaging app or another 3rd party one there is not a way for a different application to try to stop the SMS from being sent (this ability would almost certainly get abused.)
I think there are apps meant for use when driving that will block incoming texts from being shown to user, maybe look in to those, if there is a way to do outgoing maybe they'll have figured it out. I don't think it is going to be possible on a stock device though.

Related

Can I suppress Send SMS option when calling ACTION_DIAL intent

My team is developing an Android app that includes the ability to call and talk to customer support. We are calling an Intent with ACTION_DIAL, which brings up the dialer with the phone number pre-populated, as expected. In the device emulator, we also see links to Create a new Contact and Add to a Contact, which are fine, but we want to suppress the Send SMS link, since there is no way for us to read messages sent to that number. Ideally, I'd like to be able to pass a parameter or change a setting that disables SMS messaging for that one invocation, but I'm open to other solutions. Searches that I've done haven't turned up anything.
Thanks in advance,
Dan
No. There's no way of knowing what dialer is being launched for action dial- OEMs all have the option of using their own, or the user can even download one of their own. There's no way of knowing what options those dialers support, and definitely no way of configuring them. Even if there was, a dialer app could ignore the configuration. You may want to use ACTION_CALL instead, which requires additional permissions but will directly call without bringing up a prefilled dialer.

How do I open and use another android app through my own after a certain event?

I'm looking to do the following, but have no idea where to start, I have some basic android understanding and hope someone can point me in the right direction.
I have an app. That app waits for an SMS from a certain number. As I understand it's not so hard to accomplish using the content://sms/inbox content resolver.
(this is as far I can manage on my own)
Upon receiving such an SMS I want to open another app (not mine) and press a certain button (or even navigate the UI until i get to it).
Is this possible to achieve? If yes, how?
I don't care how to, it can be a classy solution using libraries meant for it, or it could be brute force "record the touch input", but I really have no idea where to start in order to accomplish this.
The app you want to launch must have certain intents that you can invoke form you app when you recieve the SMS
Intent intent = getPackageManager().getLaunchIntentForPackage("com.thirdparty.package");
startActivity( intent );

Disable sending texts on Android

I want to be able to have the user press a button in the app that disables sending texts. In my googling attempts, I've seen that it might be impossible. Does anyone know how to accomplish this? My thoughts are either to disable opening the texting app or just disable the send button in the texting app.
This is not truly disabling it, as other comments have pointed out. However... you could set up a service or some sort of polling period with an alarm. You can check if a SMS app (you'll have to gather SMS packages) is open in the foreground by its package name, and then launch some activity from your application, essentially blocking the SMS app.
Granted, this is horrible UX and is very hacky, but it could work for preventing the sending of SMS by preventing the user from actually using any SMS apps.
It's not possible, because "texting app" is a system application, which have no open API's for it's UI customization. All you can do - just create custom texting application and replace with a system one.
Even if one somehow found a way to disable the texting app, it does not account for the ContentProvider's that expose the SMS and MMS data to any app that asks for it nor the API's that allow any app that asks to do so to send SMS and MMS for you. This is why you can download alternative texting apps (and why hangouts recently turned into a combination sms/chatting app).
Sorry, but you're asking to do something that requires ripping out the guts of the OS, from what I understand.

Android: How to program changes to the standard android sms GUI

I want to write an android app that changes the android standard message sms GUI giving it an extra send button. The one send button should be the usual one and the other should be the one that uses my application to send the message. How do I add this extra button in the android standard sms message GUI? Anyone got an example code on how to do this?
Kind regards
Benjamin
Ok, this you Cannot do for phones which are in the market. You will need to grab hold of the sources and come up with a custom ROM for users to flash.
However, as another option, you can build your own SMS application and let users install so. When users need to send a SMS, they will be asked whether we default/your app needs to be used. This way is a much cleaner approach and more reachable to users.

How to catch an incoming text message

I want to be able to control incoming text messages. My application is still on a "proof of concept" version and I'm trying to learn Android programming as I go.
First my application need to catch incoming text messages. And if the message is from a known number then deal with it. If not, then send the message as nothing has happened to the default text message application.
I have no doubt it can be done, but I still have some concern and I see some pitfalls at how things are done on Android.
So getting the incomming text message could be fairly easy - except when there are other messaging applications installed and maybe the user wants to have normal text messages to pop up on one of them - and it will, after my application has had a look at it first.
How to be sure my application get first pick of incoming text messages?
And after that I need to send most text messages through to any other text message application the user has chosen so the user can actually read the message my application didn't need.
Since Android uses intents that are relative at best, I don't see how I can enforce my application to get a peek at all incoming text messages, and then stop it or send it through to the default text messaging application.
Espen,
The answer to this is multi-part. Understand first that our company has resolved this problem, but the solution is temporarily proprietary, so I will answer what I can without causing conflict either here or for my company.
1) You can never insure that your App ever gets first pick. What you can do is make your processing "fast enough" that is does not matter.
2) Intents ARE an absolute if you force the issue. Our company uses a concept called intent routing. This insures that the data is sent to the appropriate app. The most basic idea is that when you receive the SMS, you create a New Intent (not the same one) and send it to the class directly. This has some special considerations, but should give you some direction.
Unfortunately, without violating my company's confidence or stackoverflow's policies, I cannot say anymore publicly until the solution is made public (within the next month).
FuzzicalLogic
Retriving all incoming messages is just setting up listener, you can do it easily see here
and after that, its fine if you are at do nothing phase, but in case you want to prevent sms to go into the native messaging app it is not advisable to prevent user.
better you wait for some time and then delete the same from SMS database.

Categories

Resources