Widget unfortunately has stopped android - java

I have a problem, Emulator shows alert dialog "Unfortunately, AppName has stopped" Thanks for help. I'd like to create clock widget.
RmWidget.java
package lek.runningman.widget;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.widget.RemoteViews;
public class RmWidget extends AppWidgetProvider {
// Define the format string for the date
private SimpleDateFormat formatter = new SimpleDateFormat(
"hh:mm:ss\nEEEEEEEE\nd-MMM-yyyy");
#Override
public void onUpdate(Context context,AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// Retrieve and format the current date
String now = formatter.format(new Date());
// Change the text in the widget
RemoteViews updateViews = new RemoteViews(
context.getPackageName(), R.layout.main);
updateViews.setTextViewText(R.id.text, now);
appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
//super.onUpdate(context, appWidgetManager, appWidgetIds);
onUpdate(context, appWidgetManager, appWidgetIds);
}
}
widget.xml
android:minWidth="220dip"
android:minHeight="146dip"
android:updatePeriodMillis="1000"
android:initialLayout="#layout/main">
</appwidget-provider>
main.xml
<TextView
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:text="#string/app_name"
android:textStyle="bold"
android:typeface="monospace"
android:textColor="#android:color/white"
android:textSize="18sp" />
</LinearLayout>
RmWidget Manefest.xml
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<receiver
android:name=".RmWidget"
android:label="#string/widget_name" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
</application>
</manifest>

Endless recursion for onUpdate, calling onUpdate on last line. Simply remove call.

Create the following method:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout_filename);
}
It is essential to initialize layout otherwise it will give some issues.

Related

Android Widget freezes after some time

I have made a counter widget. There are two buttons, one to increase and one to decrease the number. The number is displayed on a TextView. At first everything works just fine, but after some time (usually around an hour) the Textview freezes i.e. I click the buttons but the number doesen't change.
When I click the buttons, the "clicking animation" is still played, so the buttons might still work.
When I remove the widget and replace it again, the widget starts to work again but the same problem occurs after around the same time.
The code is here:
WidgetProvider
package com.example.myapplication;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class WidgetProvider1 extends AppWidgetProvider {
String widgettextviewtext;
final String INCREASE= "sdfjkldjldkf";
final String DECREASE = "skdhbcvouweoaior";
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
MainActivity.zahl = 15;
remoteViews.setTextViewText(R.id.textView, ""+MainActivity.zahl);
remoteViews.setOnClickPendingIntent(R.id.button3,onClickPendingIntent(context,ZAHLGROESSER) );
remoteViews.setOnClickPendingIntent(R.id.button2,onClickPendingIntent(context,ZAHLKLEINER) );
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
updateWidgetNow(context,remoteViews);
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
#Override
public void onReceive(Context context, Intent intent) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
//if increase button is clicked
if(intent.getAction().equals(INCREASE)){
if(MainActivity.zahl == 15) {
Toast.makeText(context, "STOOOP!!!", Toast.LENGTH_SHORT).show();
}else{
MainActivity.number = MainActivity.number+1;
String text=""+ MainActivity.number;
remoteViews.setTextViewText(R.id.textView, text);
updateWidgetNow(context, remoteViews);
}
}
//if decrease button is clicked
if(intent.getAction().equals(DECREASE)) {
if (MainActivity.number == 0) {
Toast.makeText(context, "Hurray!", Toast.LENGTH_SHORT).show();
}else{
MainActivity.number = MainActivity.number - 1;
String text = "" + MainActivity.number;
remoteViews.setTextViewText(R.id.textView, text);
updateWidgetNow(context, remoteViews);
}
}
super.onReceive(context, intent);
}
public void updateWidgetNow (Context context, RemoteViews remoteViews){
ComponentName widgetComponent = new ComponentName(context, WidgetProvider1.class);
AppWidgetManager.getInstance(context).updateAppWidget(widgetComponent, remoteViews);
}
public PendingIntent onClickPendingIntent (Context context, String stringAction){
Intent onClickIntent = new Intent(context, WidgetProvider1.class);
onClickIntent.setAction(stringAction);
return PendingIntent.getBroadcast(context,0,onClickIntent,PendingIntent.FLAG_UPDATE_CURRENT);
}
}
MainActivity:
package com.example.myapplication;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
public static int number = 15;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myapplication">
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.MyApplication"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/Theme.MyApplication">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.myapplication.WidgetProvider1"
android:label="Tutorial Widget"
android:exported="true"
>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info"
/>
</receiver>
</application>
</manifest>
WidgetInfo:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="180dp"
android:minWidth="180dp"
android:initialLayout="#layout/widget_layout"
android:previewImage="#drawable/widget_preview"
android:widgetCategory="home_screen"
android:resizeMode="horizontal|vertical"
>
</appwidget-provider>
WidgeLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:theme="#style/Theme.AppCompat.Light"
android:id="#+id/widget_layout"
>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_centerInParent="true"
android:text="1"
android:textAlignment="center"
android:textSize="150dp"
android:textColor="#color/white"
/>
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/textView"
android:layout_marginBottom="1dp"
android:text="increase"
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"
android:textSize="30dp"
/>
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/textView"
android:layout_marginTop="1dp"
android:text="decrease"
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"
android:textSize="30dp"
/>
</RelativeLayout>

Why my app is crashing on clicking any of the buttons?

I am trying to use intents but on clicking any of the buttons,the app stops working and terminates.I am a beginner and I couldn't find the reason.I am providing my xml file,java file and menifest file.Please someone help.
here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.shreya.intents.MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Set Alarm"
android:id="#+id/alarm"
android:onClick="setAlarm"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Map"
android:id="#+id/map"
android:onClick="seeMap"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mail"
android:id="#+id/mail"
android:onClick="email"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email ID"
android:inputType="textCapWords"
android:id="#+id/address"/>
</LinearLayout>
And here is my .java file:
package com.example.shreya.intents;
import android.content.Intent;
import android.net.Uri;
import android.provider.AlarmClock;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.util.Locale;
import static com.example.shreya.intents.R.id.alarm;
public class MainActivity extends AppCompatActivity {
private Button mail;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void setAlarm(){
String message="Wake Up";
int hour=7;
int minutes=0;
Intent intent = new Intent(AlarmClock.ACTION_SHOW_ALARMS);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
public void seeMap(){
String uri = String.format(Locale.ENGLISH, "geo:%f,%f", 28.699884, 77.273075);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
if(intent.resolveActivity(getPackageManager())!=null)
startActivity(intent);
}
public void email(){
EditText mail=(EditText)findViewById(R.id.address);
String add=mail.getText().toString();
composeEmail(add,"shreya");
}
public void composeEmail(String addresses, String subject) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT,"hello");
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
}
And finally this is my menifest file:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
You have to add parameter View view to your onClick methods.
For example:
public void setAlarm(View view){
}
Add that parameter to other onClick methods also: email and seeMap.
Under the hood, the system uses reflection to figure out the exact onClick method in the Activity and the system uses the following exact pattern to find the method: a public void method with the specified method name in the xml onClick attribute and has a single parameter View.

Null pointer exception using Time Pickers

I'm trying to make a simple app that opens the time picker dialog when you click the "Check" button, and once you set the time and tap "OK", it checks the system time and outputs whether it is correct. However, I am given a null pointer exception on line 21 of MainActivity.java. At the moment the code is simply set up to bring up the dialog once "Check" is tapped.
MainActivity.java
package com.example.timechecker;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.view.View;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public FragmentManager getSupportFragmentManager() {
return null;
}
public void checkTime(View view) {
DialogFragment newFragment = new TimePickerFragment();
newFragment.show(getSupportFragmentManager(), "timePicker");
}
}
TimePickerFragment.java
package com.example.timechecker;
import java.util.Calendar;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.text.format.DateFormat;
import android.widget.TimePicker;
public class TimePickerFragment extends DialogFragment
implements TimePickerDialog.OnTimeSetListener {
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute,
DateFormat.is24HourFormat(getActivity()));
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Do something with the time chosen by the user
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timechecker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.timechecker.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.timechecker.TimePickerFragment"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
Activity_Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="#+id/whatTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What time is it?"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/check"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="checkTime"
android:text="Check" />
</LinearLayout>
Ah i see what is happening here.
public FragmentManager getSupportFragmentManager() {
return null;
}
public void checkTime(View view) {
DialogFragment newFragment = new TimePickerFragment();
newFragment.show(getSupportFragmentManager(), "timePicker");
}
You are overriding getSupportFragmentManager to return null, and after that you call the method to show the dialog, looks like you created the nullpointer on purpose? =D

Widget not showing in widget list

I have an app and have decided to add a widget to it, I've followed all the official documentation for it, but when I install the app on my Galaxy Nexus, the widget doesn't appear in the app/widget list.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dysign.livetubecountdown"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.dysign.livetubecountdown.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.dysign.livetubecountdown.Widget" android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<intent-filter>
<action android:name="android.appwidget,action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#xml/widget_provider" />
</receiver>
</application>
widget_provider.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="80dp"
android:minWidth="80dp"
android:minResizeHeight="40dp"
android:minResizeWidth="40dp"
android:updatePeriodMillis="86400000"
android:initialLayout="#layout/widget_main"
android:previewImage="#drawable/ic_launcher"
android:widgetCategory="home_screen"
android:resizeMode="horizontal|vertical">
</appwidget-provider>
widget_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/widgetTextView"/>
</FrameLayout>
Widget.java
package com.dysign.livetubecountdown;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.widget.RemoteViews;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
public class Widget extends AppWidgetProvider {
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerClass(context, appWidgetManager), 1, 1000);
}
private class TimerClass extends TimerTask {
RemoteViews remoteViews;
AppWidgetManager appWidgetManager;
ComponentName thisWidget;
DateFormat format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, Locale.getDefault());
public TimerClass(Context context, AppWidgetManager appWidgetManager) {
this.appWidgetManager = appWidgetManager;
remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_main);
thisWidget = new ComponentName(context, Widget.class);
}
#Override
public void run() {
remoteViews.setTextViewText(R.id.widgetTextView, "TIME = " +format.format(new Date()));
appWidgetManager.updateAppWidget(thisWidget, remoteViews);
}
}
}
I've been looking all over the web to try to fix this, but every suggestion I try just doesn't work. Also there are no errors in LogCat or any mention of anything widget related.
Any help is much appreciated, thanks!
The problem turned out to be a typo in the manifest.
<action android:name="android.appwidget,action.APPWIDGET_UPDATE" />
Should of been:
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Notice the comma after android.appwidget.
I have experienced the same problem a few times.
The thing that helped me was rebooting my phone, after that the widget started appearing in the widget list. Why is this happening i dont know i have googled and found out that many have similar problems, that it even happens that users install the app from the Market and the widget doesnt appear in the list.
Some solutions that were offered by others: re-installing the app(didn work for me), starting its main activity a few times(also nothing), rebooting phone(this one worked for me, since it even happened during development that the widget works fine for days and the suddenly it was missing in the list when re-installing from eclipse??? Rebooting the phone helped me.
Hope it helps!

Android Widget not working

I have no idea what's going on. My OnReceive method is never called. It's probably something in the manifest.
Widget Provider:
package com.net_refresh;
import android.app.PendingIntent;
import android.appwidget.AppWidgetProvider;
import android.content.Intent;
import android.content.Context;
import android.provider.Settings;
import android.view.View;
import android.widget.RemoteViews;
import android.appwidget.AppWidgetManager;
public class NetRefreshWidget extends AppWidgetProvider
{
private static final String ACTION_WIDGET_RECEIVER = "ActionRecieverWidget";
#Override
public void onUpdate(Context context, AppWidgetManager appwidgetmanager, int[] appWidgetIds)
{
final int length = appWidgetIds.length;
for (int i=0; i<length; i++)
{
int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(context, NetRefreshWidget.class);
intent.setAction(ACTION_WIDGET_RECEIVER);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_initial_layout);
views.setOnClickPendingIntent(R.id.button1, pendingIntent);
appwidgetmanager.updateAppWidget(appWidgetId, views);
}
}
#Override
public void onDeleted(Context context, int[] appWidgetIds)
{
}
#Override
public void onEnabled(Context context)
{
}
#Override
public void onDisabled(Context context)
{
}
#Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals(ACTION_WIDGET_RECEIVER))
{
//Top secret code here.
}
}
Manifest:
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.net_refresh" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="7"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name=".NetRefresh">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name=".NetRefreshWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#xml/widget_info"/>
</receiver>
</application>
</manifest>
Widget info XML:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="72dp"
android:minHeight="72dp"
android:updatePeriodMillis="0"
android:initialLayout="#layout/widget_initial_layout"
>
</appwidget-provider>
Widget layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget_root"
android:layout_width="72dp"
android:orientation="vertical"
android:layout_height="72dp"
>
<Button android:text="Button" android:layout_width="wrap_content" android:id="#+id/button1" android:layout_height="wrap_content"></Button>
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="#drawable/icon" android:clickable="true" android:adjustViewBounds="false" android:id="#+id/img_refresh" android:layout_toRightOf="#+id/button1" android:layout_alignTop="#+id/button1" android:layout_alignBottom="#+id/button1">
</ImageView>
</RelativeLayout>
The code says nothing without you to point the compiler's errors & warnings.
Anyway you can wrap your code into .apk and install it by yourself into your device, BUT this is the curve way, because everyone I know are using the eclipse and SDK tools.
Have you tried using this: <uses-permission android:name="android.permission.INTERNET" />. It may solve it.
I figured it out a while back. I don't remember what I changed exactly but I at least added this line:
<action android:name="android.appwidget.action.ACTION_WIDGET_RECEIVER"/>
To the manifest, next to:
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
Very simple solution, now that I have an understanding of how broadcasts work.

Categories

Resources