我无法启动新活动,点击列表视图中的项目.我希望那onItemClick
可以打开ApkInfoActivity
..其实当我点击什么都没发生.
protected void onItemClick(ListView l, View v, int position, long id, AdapterView<?> parent) {
super.onListItemClick(l, v, position, id);
final ApplicationInfo app = applist.get(position);
PackageInfo packageInfo = (PackageInfo) parent.getItemAtPosition(position);
AppDataActivity appData = (AppDataActivity) getApplicationContext();
appData.setPackageInfo(packageInfo);
Intent appInfo = new Intent(getApplicationContext(), ApkInfoActivity.class);
startActivity(appInfo);
}
Run Code Online (Sandbox Code Playgroud)
我找不到问题.我怎么解决?
用logcat编辑:
10-29 17:14:07.710: E/AndroidRuntime(3535): FATAL EXCEPTION: main
10-29 17:14:07.710: E/AndroidRuntime(3535): java.lang.ClassCastException: android.content.pm.ApplicationInfo cannot be cast to android.content.pm.PackageInfo
10-29 17:14:07.710: E/AndroidRuntime(3535): at com.dd.application.MainActivity.onItemClick(MainActivity.java:369)
10-29 17:14:07.710: E/AndroidRuntime(3535): at android.widget.AdapterView.performItemClick(AdapterView.java:297)
10-29 17:14:07.710: E/AndroidRuntime(3535): at android.widget.AbsListView.performItemClick(AbsListView.java:1149)
10-29 …
Run Code Online (Sandbox Code Playgroud) android package-managers android-listview android-activity onclicklistener
你知道吗
好吧,我想创建像这个屏幕的东西.当我第一次打开应用程序时,我想打开这个屏幕并显示一个上下文..怎么可能?我不知道是什么搜索这种类型的东西..
我的通知是服务(service.java),当检查首选项屏幕中的checkboxpreference时,服务所做的是启动电池电量通知.现在不起作用的是在MainActivity
单击通知时输入的意图.这是代码
if(mprefs.getBoolean("notification_a", false)==true){
notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.setOngoing(true);
notificationBuilder.setContentTitle("Battery Stats Informations");
notificationBuilder.setContentText("Carica residua: " +level+"%" + " " + "Temperatura: " +temperature+ "°C");
//notificationBuilder.setTicker("Informazioni batteria");
notificationBuilder.setWhen(System.currentTimeMillis());
notificationBuilder.setSmallIcon(R.drawable.icon_small_not);
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, 0);
notificationBuilder.setContentIntent(contentIntent);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Notification not=notificationBuilder.build();
mNotificationManager.notify(SIMPLE_NOTIFICATION_ID,not);
} else {
mNotificationManager.cancelAll();
}
Run Code Online (Sandbox Code Playgroud)
意图Intent notificationIntent = new Intent(context, MainActivity.class
不起作用.有帮助吗?
android android-intent android-notifications android-pendingintent
如何获得带小数的电池温度?其实我可以用它来计算
int temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0);
Run Code Online (Sandbox Code Playgroud)
但通过这种方式,结果将是例如36 °C
..我想要一些东西给我看我36.4 °C
怎么办?
我正在尝试每个代码将文件夹中的所有内容复制到另一个但我无法做到!我正在尝试在我的Android设备中使用终端模拟器中的代码,因为我需要在我的应用程序中使用该代码.这是我使用的最后一个代码不起作用:
#!/bash/sh
srcdir="/data/app"
dstdir="/sdcard/prova1"
for f in ${srcdir}/*.apk
do
cp $f $dstdir $dstfile
done
Run Code Online (Sandbox Code Playgroud)
终端说:
: not found
' unespectedsyntax error: 'do
Run Code Online (Sandbox Code Playgroud)
谁能帮我?这些可能性很好:
1)将/ data/app文件夹中的所有文件复制到/ sdcard/prova1
2)直接复制prova1中的文件夹应用程序
3)使用执行这两件事之一的java代码.
我有根,所以我可以做这个操作.
我想创建一个首选项屏幕,其中有三个复选框;第一个是可单击的,而其他两个则只有在选中第一个后才能单击。
我怎样才能做到这一点?我看过本教程,但是只有一个复选框。谁能帮我?
android preferenceactivity android-preferences preferencescreen android-checkbox
如何在通知栏中创建一个在5秒后消失的通知?例如; 这是通知代码:
Intent intent = new Intent(this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Build notification
// Actions are just fake
Notification noti = new Notification.Builder(this)
.setContentTitle("Notification")
.setContentText("This is a notification that didsappears in 5 seconds")
.setSmallIcon(R.drawable.icon)
.setContentIntent(pIntent)
.addAction(R.drawable.icon)
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
Run Code Online (Sandbox Code Playgroud)
从这段代码开始,如何创建5秒后消失的通知?
我MainActivity
的菜单中有一个项目,我称之为另一项活动HomeActivity
:
public class HomeActivity extends Activity
{
private static final String TAG = "CpuSpy";
private CpuSpyApp _app = null;
// the views
private LinearLayout _uiStatesView = null;
private TextView _uiAdditionalStates = null;
private TextView _uiTotalStateTime = null;
private TextView _uiHeaderAdditionalStates = null;
private TextView _uiHeaderTotalStateTime = null;
private TextView _uiStatesWarning = null;
private TextView _uiKernelString = null;
/** whether or not we're updating the data in the background */
private boolean _updatingData = false;
/** Initialize …
Run Code Online (Sandbox Code Playgroud) 我有一个excel文件,在第一列(A)我有一些这样的日期:
17/10/2013
18/10/2013
19/10/2013
20/10/2013
21/10/2013
22/10/2013
Run Code Online (Sandbox Code Playgroud)
其他列包含一些数据.我需要创建一个输入框,将日期范围内的所有内容都包含在内.我的意思是; 我点击按钮,它会显示一个弹出窗口:
insert start date: 17/10/2013 (i can decide the date)
insert end date: 20/10/2013 (i can decide the date)
Run Code Online (Sandbox Code Playgroud)
然后我可以放一个宏我已经完成了.所以我的宏只读取该范围内的数据.可能吗?
一位用户告诉我他无法在我的应用程序中打开一个片段,因为他遇到了崩溃.我有logcat:
java.lang.NullPointerException
at com.dd.androreboot.devicecontrolfragment.onCreateView(devicecontrolfragment.java:162)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
at android.app.BackStackRecord.run(BackStackRecord.java:635)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1399)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
在第162行我有这个代码:
ConnectivityManager connManager = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
datatoggle = (ToggleButton)v.findViewById(R.id.datatoggle);
datatoggle.setChecked(mobile.isConnectedOrConnecting()); //line 162
Run Code Online (Sandbox Code Playgroud)
这部分代码需要检查3g是否已连接,如果是,则切换按钮状态变为true.它适用于我试过的每个设备,但不适用于这个:Galaxy Note 10.1(p4notewifi).有帮助吗?
android ×8
java ×2
bash ×1
battery ×1
casting ×1
copy-paste ×1
date-range ×1
excel ×1
excel-vba ×1
inputbox ×1
instructions ×1
shell ×1
statusbar ×1
temperature ×1
togglebutton ×1
vba ×1