请问一下在程序里如何添加一个widget到桌面网上搜了好多都说要用户手动添加
有办法用程序自动添加到桌面么
有办法用程序自动添加到桌面么
解决方案 »
- android接收不到udp包吗?
- java.lang.IllegalArgumentException
- android实现一个简单的计算器要求在后台service运算在前台显示结果怎么做?
- 创建AudioRecord时 报Unknown PCM AndroidRecord 是什么原因?
- [Android UI界面] 实时刷新GirdView时 点击事件无效?!
- 做activity跳转 怎么报错了。。。
- 请教adb截图问题,/dev/graphics/fb0
- 实现手机转图不转的效果
- cocos2d-x安卓游戏开发.兄弟们介绍一款测试机吧.模拟器太慢,受不了.
- java.net.SocketException: Socket closed
- 为ExpandableListView的childView添加header
- 把一个虚拟sd卡内的文件和文件夹以树形结构显示在虚拟机上要怎么做啊
是需要在开机的时候自动添加到桌面的话
需要在手机的data/system/appwidgets.xml里面加上你的widget
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/myButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_button1"
/>
</LinearLayout>
在代码中使用要导入包
import android.widget.TextView;
import android.widget.Button;然后可以通过findViewById去获取控件Id,再执行相关操作
你需要手动计算,你的widget占多少格,当前桌面有的第几个屏有多少空格,你可以看下launcher的代码,快捷方式的创建同样的道理。