I copy and paste the code, it can be really stupid ...
I have a custom dialog that appears after clicking my widget:
public class ClockHandler extends Activity {
final Context context = this;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.clockhandler);
dialog.setTitle("Available Clocks...");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("System Clocks");
text.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Searching for System Clock...", Toast.LENGTH_SHORT).show();
}
});
TextView text2 = (TextView) dialog.findViewById(R.id.text2);
text2.setText("More Clock Widgets!");
text2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Clock Widget Gallery Coming SOON!!!", Toast.LENGTH_LONG).show();
}
});
dialog.show();
}
}
I want to use an https://stackoverflow.com/a/318828/... solution on click TextView text. I tried all kinds of mechanisms, including:
using https://stackoverflow.com/a/318828/ ... in a separate file SystemClock.java, and then try to call this from mine ClockHandlerwith things like
final RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.clockhandler);
final PendingIntent intent = SystemClock.getClockIntent(context);
if (intent != null){
rv.setOnClickPendingIntent(R.id.text, intent);
and
Intent intent = new Intent();
PendingIntent.getActivity(context, 0, intent, 0);
as well as including https://stackoverflow.com/a/318828/ ... a solution in the ClockHandler file underpublic void onClick(View v) {
source
share