title: Android widget start activity when imageview is clicked
body: <p>I am developing an analog clock widget for andriod I have an imageview in the widget, i need to add a click listener to it so when it is clicked it will start an activity (facebook share activity) here is the  code</p>
  
  <pre><code>public class Widget extends AppWidgetProvider
  {    
      public void onReceive(Context context, Intent intent)
      { 
          super.onReceive(context, intent);
          PackageManager packageManager = context.getPackageManager();
          Intent alarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);
          Log.d("ARH","CLICKK");
          String clockImpls[][] = {
                  {"HTC Alarm Clock", "com.htc.android.worldclock", "com.htc.android.worldclock.WorldClockTabControl" },
                  {"Standar Alarm Clock", "com.android.deskclock", "com.android.deskclock.AlarmClock"},
                  {"Froyo Nexus Alarm Clock", "com.google.android.deskclock", "com.android.deskclock.DeskClock"},
                  {"Moto Blur Alarm Clock", "com.motorola.blur.alarmclock",  "com.motorola.blur.alarmclock.AlarmClock"},
                  {"Samsung Galaxy Clock", "com.sec.android.app.clockpackage","com.sec.android.app.clockpackage.ClockPackage"}
          };
  
          boolean foundClockImpl = false;
  
          for(int i=0; i&lt;clockImpls.length; i++) {
              String vendor = clockImpls[i][0];
              String packageName = clockImpls[i][1];
              String className = clockImpls[i][2];
              try {
                  ComponentName cn = new ComponentName(packageName, className);
                  ActivityInfo aInfo = packageManager.getActivityInfo(cn, PackageManager.GET_META_DATA);
                  alarmClockIntent.setComponent(cn);   
                  foundClockImpl = true;
              } catch (Exception e) {
                  System.out.println(vendor + " does not exists");
              }
          }
  
          if (foundClockImpl) {
              PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, alarmClockIntent, 0);
              String action = intent.getAction();
              Log.v("info",action);
              if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action))
              {
  
                  RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
  
  
                  Intent fbook = new Intent(context,FacebookShare.class);
                  PendingIntent fbookPIntent = PendingIntent.getActivity(context, 0, fbook, 0);  
  
                  views.setOnClickPendingIntent(R.id.facebooksharebtn, fbookPIntent); 
                  AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views);
              }else{ 
              }
          }
  
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p>and the Activity which needs to appear is </p>
  
  <pre><code>public class FacebookShare extends Activity {
  
  
      Facebook facebook = new Facebook("304105172993733");  
      boolean isLoggedIn = false;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.facebook);
  
          facebook.authorize(this, new String[]{"publish_stream"}, new DialogListener(){
  
              public void onComplete(Bundle values) {
  
                  Log.d("COMPLETE","AUTH COMPLETE. VALUES: "+values.size());
                  Log.d("AUTH TOKEN","== "+values.getString(Facebook.TOKEN));
                  updateStatus(values.getString(Facebook.TOKEN));
              }
  
              public void onFacebookError(FacebookError e) {
                  Log.d("FACEBOOK ERROR","FB ERROR. MSG: "+e.getMessage()+", CAUSE: "+e.getCause());
              }
  
              public void onError(DialogError e) {
                  Log.e("ERROR","AUTH ERROR. MSG: "+e.getMessage()+", CAUSE: "+e.getCause());
              }
  
              public void onCancel() {
                  Log.d("CANCELLED","AUTH CANCELLED");
              }
          });
      }
  
      public void updateStatus(String accessToken){
          try {
              Bundle bundle = new Bundle();
              bundle.putString("message", "test update");  
              bundle.putString(Facebook.TOKEN,accessToken); 
              String response = facebook.request("me/feed",bundle,"POST");
              Log.d("UPDATE RESPONSE",""+response);
          } catch (MalformedURLException e) {
              Log.e("MALFORMED URL",""+e.getMessage());
          } catch (IOException e) {
              Log.e("IOEX",""+e.getMessage());
          }
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          Log.d("onActivityResult","onActivityResult");
          facebook.authorizeCallback(requestCode, resultCode, data);
      }
  
  }
  </code></pre>
  
  <p>both are in same package </p>
  
  <p>here is the exception that I get when I click on the imageview </p>
  
  <blockquote>
    <p>E/AndroidRuntime(1130): java.lang.RuntimeException: Unable to start
    activity
    ComponentInfo{com.mnet.rockwell.widgets.AnalogClock/com.mnet.widgets.AnalogClock.FacebookShare}:
    android.view.InflateException: Binary XML file line #31: Error
    inflating class android.widget.FrameLayout</p>
  </blockquote>
  
  <p>also this I dont get any logs on logcat</p>
  
  <p>here is what I have tried for log</p>
  
  <pre><code> Log.d("ARH","CLICKK");
  Log.e("ARH","CLICKK");
  Log.v("ARH","CLICKK");
  Log.i("ARH","CLICKK");
  </code></pre>
  
  <p>I am new to Android development but I am a Java developer, please any suggestions</p>
  
  <p>here is facebook.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Thank You For Sharing Rockwell Widget" /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_below="@+id/textView1"
          android:layout_marginRight="27dp"
          android:layout_marginTop="40dp"
          android:text="   Close   " /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>