小编Kev*_*ker的帖子

如何在非活动类(LocationManager)中使用getSystemService?

我无法将主要活动OnCreate方法中的任务卸载到另一个类来完成繁重的工作.

当我尝试从非Activity类调用getSystemService时会抛出异常.

任何帮助将不胜感激 :)

lmt.java:

package com.atClass.lmt;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.location.Location;

public class lmt extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        fyl lfyl = new fyl();
        Location location = lfyl.getLocation();
        String latLongString = lfyl.updateWithNewLocation(location);

        TextView myLocationText = (TextView)findViewById(R.id.myLocationText);
        myLocationText.setText("Your current position is:\n" + latLongString);
    }
}
Run Code Online (Sandbox Code Playgroud)

fyl.java

package com.atClass.lmt;

import android.app.Activity;
import android.os.Bundle;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
import android.content.Context;

public class fyl {
    public Location getLocation(){
        LocationManager locationManager; …
Run Code Online (Sandbox Code Playgroud)

android

171
推荐指数
3
解决办法
23万
查看次数

禁用EditText闪烁光标

有谁知道如何在EditText视图中禁用闪烁的光标?

android android-edittext

169
推荐指数
5
解决办法
11万
查看次数

查找带标签的所有视图?

我希望在指定活动中查找具有标签"balloon"的所有视图,例如然后使用setVisibilityto 隐藏它们GONE.

有谁知道如何检索具有给定标记的视图列表?

android

37
推荐指数
3
解决办法
3万
查看次数

Android和Dalvik - 获取对象的大小

众所周知,Java 5引入了Instrumentation轻松获取对象大小的能力.在Android和Dalvik上有这样的方法吗?

java.lang.instrument软件包在Android上不可用.

java android dalvik

20
推荐指数
1
解决办法
9181
查看次数

ICS上的本机堆栈跟踪?

由于某种原因,我不能在我这里的ICS设备上发生本地(C/C++)地址/堆栈跟踪.

在我的Nexus 7上,当本机库崩溃时,不会输出任何内容.log.redirect-stdio设置为通过时设置为1,/system/default.prop并且/data/local.prop都不起作用.

我试着设置log.redirect-stdiotrue使用stop,setprop,start的命令,但仍然没有原生的堆栈跟踪是输出到logcat的.

谷歌我的意思是来吧......我每天都因为与我的错误,不可预测的关系而对Google产生越来越多的信心.

android stack-trace android-ndk nexus-s android-4.0-ice-cream-sandwich

19
推荐指数
1
解决办法
1398
查看次数

将视图/布局扩展到另一个布局?

我正在寻找一种方法将另一个布局膨胀到android中的第一个布局.怎么会这样做?这是两个XML文件.第一个是主要布局,第二个是我想要扩展到第一个布局.

我不能只包括布局,因为我将使用此方法将其他布局膨胀为线框.

代码也位于:http://pastebin.com/wjZ4s1cs,因为stackoverflow不喜欢XML.

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ff000000"
    >
    <TextView
        android:id="@+id/headerMenuText"
        android:text="@string/main_menu_title"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:textSize="16pt"
        android:paddingTop="10px"
        android:paddingBottom="10px"
        android:gravity="center"
    >
    </TextView>
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_y="100dip"
        android:gravity="center"
        android:layout_gravity="center"
    >
        <TableRow
            android:gravity="center"
            android:layout_gravity="center">
            <ImageView
                android:id="@+id/menuItem1"
                android:layout_height="101dip"
                android:layout_width="89dip"
                android:src="@drawable/icon_settings"
            ></ImageView>

            <ImageView
                android:id="@+id/menuItem2"
                android:layout_height="101dip"
                android:layout_width="89dip"
                android:src="@drawable/icon_system_restart"
            ></ImageView>

            <ImageView
                android:id="@+id/menuItem3"
                android:layout_height="101dip"
                android:layout_width="89dip"
                android:src="@drawable/icon_game_history"
            ></ImageView>

            <ImageView
                android:id="@+id/menuItem4"
                android:layout_height="101dip"
                android:layout_width="89dip"
                android:src="@drawable/icon_game_correction"
            ></ImageView>

            <ImageView
                android:id="@+id/menuItem5"
                android:layout_height="101dip"
                android:layout_width="89dip"
                android:src="@drawable/icon_game_other"
            ></ImageView>
        </TableRow>

        <TableRow android:gravity="center">
            <TextView
                android:id="@+id/menuItemText1"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/main_menu_item_text_1"
                android:layout_gravity="center"
                android:gravity="center"
            ></TextView>

            <TextView …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-view

18
推荐指数
2
解决办法
4万
查看次数

卸载我的Android应用程序时可以调用代码吗?

有没有人知道在卸载我的应用程序时是否可以覆盖特定方法?发生这种情况时,最好从服务器端数据库中删除这些用户.

android

15
推荐指数
1
解决办法
9746
查看次数

Oracle SQL命令在子查询中的问题!

我试图在Oracle SQL中运行子查询,它不会让我订购子查询列.对子查询进行排序非常重要,因为Oracle似乎会随意选择哪些返回列返回主查询.

select ps.id, ps.created_date, pst.last_updated, pst.from_state, pst.to_state,
        (select last_updated from mwcrm.process_state_transition subpst
            where subpst.last_updated > pst.last_updated
            and subpst.process_state = ps.id
            and rownum = 1) as next_response
        from mwcrm.process_state ps, mwcrm.process_state_transition pst
        where ps.created_date > sysdate - 1/24
        and ps.id=pst.process_state
        order by ps.id asc

select ps.id, ps.created_date, pst.last_updated, pst.from_state, pst.to_state,
        (select last_updated from mwcrm.process_state_transition subpst
            where subpst.last_updated > pst.last_updated
            and subpst.process_state = ps.id
            and rownum = 1
            order by subpst.last_updated asc) as next_response
        from mwcrm.process_state ps, mwcrm.process_state_transition pst
        where ps.created_date > sysdate - 1/24 …

sql oracle

14
推荐指数
3
解决办法
6万
查看次数

使用超级用户构建Android

有没有人知道如何在从源代码(AOSP)构建android时包含超级用户权限?

android root android-source

14
推荐指数
1
解决办法
2万
查看次数

Android NDK构建 - 包括LOCAL_SHARED_LIBRARIES?

我在Android NDK下构建项目时遇到问题.很可能是由于没有包含正确的共享/静态库.那些作为-lsomeLib我添加了,但是作为LOCAL_SHARED_LIBRARIES的那些没有被包括在内似乎......

我的Android.mk包含以下内容

LOCAL_SHARED_LIBRARIES + = libutils libmedia libz libbinder

  1. ndk-build实际上在哪里寻找这些库?
  2. 如果我不包含-lutils -lmedia -lz -lbinder,我甚至无法得到链接器错误.我有一种感觉,包括-LsomeDir和-lsomeLib不是添加它们的正确方法.

这是完整的Android.mk.

LOCAL_PATH := /Users/kevin/Desktop/player2/videoplayer/videoplayer/jni
LIBPLAYER_PATH := $(LOCAL_PATH)/../../LibPlayer

include $(CLEAR_VARS)

$(warning Android make file: $(LOCAL_PATH)/Android.mk)
$(warning Android sysroot: $(SYSROOT))
$(warning Additional LD_LIBS: $(LOCAL_PATH)/lib)

ifeq ($(BUILD_ID),MID)
        LOCAL_CFLAGS += -DENABLE_FREE_SCALE
endif

LOCAL_MODULE    := libamplayerjni
LOCAL_SRC_FILES := com_farcore_playerservice_AmPlayer.c sys_conf.c
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES := $(LIBPLAYER_PATH)/amplayer/player/include \
    $(LIBPLAYER_PATH)/amplayer/control/include \
    $(LIBPLAYER_PATH)/amcodec/include \
    $(LIBPLAYER_PATH)/amffmpeg \
    $(JNI_H_INCLUDE) \
    /Android/ndk/build/tools/android-9-toolchain/sysroot/usr/include \
    /Android/ndk/build/platforms/android-9/arch-arm/usr/include \
    /Android/source_2.3/system/core/include \
    /Android/source_2.3/frameworks/base/include

LOCAL_LDLIBS := -L/Users/kevin/Desktop/player2/videoplayer/videoplayer/jni/lib -L$(SYSROOT)/usr/lib -llog -lz -lm -ldl …
Run Code Online (Sandbox Code Playgroud)

c++ android android-ndk

11
推荐指数
1
解决办法
2万
查看次数