Hi I am making Android application and I want to make a widget for it. The concept of application is that it gets stt(speech-to-text) string from 'Voicemain_Activity' and put string to created field in 'AddActivity'.And in 'AddActivity' there are a button to call 'Voicemain_Activity'. I was trying to make it to start 'Voicemain_Activity'. So I made widget codes like this. public class MyAppWidget extends AppWidgetProvider {
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
//CharSequence widgetText = context.getString(R.string.appwidget_text);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.my_app_widget);
// views.setTextViewText(R.id.appwidget_text, widgetText);
Intent intent=new Intent(context, AddActivity.class);
PendingIntent pe=PendingIntent.getActivity(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.imageButton_voice, pe);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context,appWidgetManager,appWidgetIds);
// There may be multiple widgets active, so update all of them
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
@Override
public void onEnabled(Context context) {
// Enter relevant functionality for when the first widget is created
}
@Override
public void onDisabled(Context context) {
// Enter relevant functionality for when the last widget is disabled
}
}
the 'AddActivity' that makes to get 'Voicemain_Activity' looks like this.
@Override
public void onClick(View v) {
int view = v.getId();
if(view == R.id.Bacode){
finish();
}
else if(view == R.id.Voice){
startActivityForResult(new Intent(this, VoiceMain_Activity.class), MY_UI);
}
}
But this code made the widget to just show me the 'Voicemain_Activity' screen and didn't get the string nor put it to 'AddActivity'. How can I make it to work?