DeveloperCRO
Lurker
Hello, i am making an app for users of one Croatian mobile network. This app is used for checking money balance of network bill, then for activating sms and internet packets with sms, and many more. I made this, and it is working perfect. Now I wan't to add an widget with 3 buttons, one button will make call on predefined number, and other two buttons will send predefined sms to predefined number. I managed to do half of the job using intents, but sms is not sent, only sms builz in app opens and i need to click send and then will sms be sent
Can you help me, to make this so that sms is sent automaticly. I tried to use smsManager, but can't get it to work...
My Code:
Can you help me, to make this so that sms is sent automaticly. I tried to use smsManager, but can't get it to work...My Code:
package cro.perger.bonbon;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Button;
import android.widget.RemoteViews;
public class HelloWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
String encodedHash = Uri.encode("#");
for (int appWidgetId : appWidgetIds) {
Intent callIntent1 = new Intent("android.intent.action.CALL",
Uri.parse("tel:*100" + encodedHash));
Intent sendIntent1 = new Intent(Intent.ACTION_VIEW);
sendIntent1.putExtra("sms_body", "Poruka 1");
sendIntent1.putExtra("address", "5556");
sendIntent1.setType("vnd.android-dir/mms-sms");
Intent sendIntent2 = new Intent(Intent.ACTION_VIEW);
sendIntent2.putExtra("sms_body", "Poruka 2");
sendIntent2.putExtra("address", "5556");
sendIntent2.setType("vnd.android-dir/mms-sms");
PendingIntent pendingIntent1 = PendingIntent.getActivity(context, 0, callIntent1, 0);
PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0, sendIntent1, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent3 = PendingIntent.getActivity(context, 0, sendIntent2, PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.button1, pendingIntent1);
views.setOnClickPendingIntent(R.id.button2, pendingIntent2);
views.setOnClickPendingIntent(R.id.button3, pendingIntent3);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
}