小编Fra*_*zzo的帖子

有没有办法从APK文件中获取源代码?

我的笔记本电脑上的硬盘驱动器崩溃了,我丢失了过去两个月一直在处理的应用程序的所有源代码.我所拥有的是从我发送给朋友时存储在我的电子邮件中的APK文件.

有没有办法从这个APK文件中提取我的源代码?

android decompiling apk android-resources

1218
推荐指数
16
解决办法
102万
查看次数

多少共享首选项太多了?

我正在编写一个游戏并将几乎所有活动游戏数据(统计数据,位置等)存储在共享首选项中.

当所有的说法和完成时,这将导致我的游戏使用超过100个共享首选项.当然,这些存储值中的大多数是小整数或布尔值.

由于我不需要对存储的数据进行任何排序,我真的不需要使用数据库....除非有一些我不知道的明显优势.

有没有理由不以这种方式使用共享首选项?性能问题?数据完整性问题?什么?

提前致谢!

android

12
推荐指数
2
解决办法
1911
查看次数

如何禁用AlertDialog内的按钮?

我想AlertDialog用3个按钮写一个.如果不满足某个条件,我希望禁用中间的中性按钮.

int playerint = settings.getPlayerInt();
int monsterint = settings.getMonsterInt();



        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage("You have Encountered a Monster");

        alertbox.setPositiveButton("Fight!",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        createMonster();
                        fight();

                    }
                });

        alertbox.setNeutralButton("Try to Outwit",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        // This should not be static
//                      createTrivia();
                        trivia();

                    }
                });

        // Return to …
Run Code Online (Sandbox Code Playgroud)

java android classcastexception android-alertdialog

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

如何让init.d中的脚本在Android中启动时执行?

我的Android应用程序功能的一部分,它放置我在init.d中编写的脚本,以便它将在每次启动时执行.(显然我的应用只适用于root用户)

这就是我在做的事情:

    busybox mount -o rw,remount /system"
    busybox cp -f /sdcard/*******/script /system/etc/init.d/script
    busybox chmod +x /etc/init.d/script
    update-rc.d script 99
Run Code Online (Sandbox Code Playgroud)

"update-rc.d script 99"行是我遇到麻烦的地方,它因"update-rc.d not found"错误而失败.

有谁知道在Android中使这个工作的正确命令是什么?

我意识到这不是发布这个问题的最合适的地方,但我已经意识到这个社区对这些问题非常了解.

linux scripting android

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

将startForeground()与意图服务一起使用

我正在尝试保持对屏幕开/关更改做出反应的服务。该服务将在一段时间内运行良好,但最终将被终止。我现在正尝试使用startForeground()来保持该进程运行,但是它似乎仍在消亡。我知道没有办法可以使进程永远存活,没有错误,但是我觉得我一定做错了,因为添加startForeground()不会增加进程的寿命。另外,作为旁注,由于未调用unregisterReceiver()(除非通过用户手动按下按钮进行手动操作),Logcat抱怨存在泄漏。.但是,由于我要完成的工作性质,接收方需要运行,直到明确告知要停止为止。

有什么建议么?

相关代码:

public class UpdateService extends IntentService {

        public UpdateService() {
        super(null);

    }

        @Override
        protected void onHandleIntent(Intent intent) {

            final int myID = 1234;


            Intent notificationintent = new Intent(this, Main.class);
            notificationintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            PendingIntent pendIntent = PendingIntent.getActivity(this, 0, notificationintent, 0);


            Notification notice = new Notification(R.drawable.icon_image, "***********", System.currentTimeMillis());


            notice.setLatestEventInfo(this, "*************", "***********", pendIntent);

            notice.flags |= Notification.FLAG_NO_CLEAR;
            startForeground(myID, notice);

            boolean screenOn = intent.getBooleanExtra("screen_state", false);


// Blah Blah Blah......


        }

        @Override
        public IBinder onBind(Intent arg0) {
            // TODO Auto-generated method stub
            return null; …
Run Code Online (Sandbox Code Playgroud)

android

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

显示所有已安装应用程序的ListView并实现OnItemClickListener的问题

我正在尝试编写一个非常简单的应用程序,它在列表视图中显示设备上每个已安装应用程序的名称.我使用Google的ListView教程作为基础.

这是我的代码:

@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        final PackageManager pm = this.getPackageManager();

        Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);

        final ArrayList<ResolveInfo> list =
                (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, 
                        PackageManager.PERMISSION_GRANTED);
        for (ResolveInfo rInfo : list)
        {
            Log.i(TAG, ": Installed Applications " + rInfo.activityInfo.
                    applicationInfo.loadLabel(pm).toString());
        }

        final ArrayAdapter<ResolveInfo> adapter = 
            new ArrayAdapter<ResolveInfo>(this, R.layout.list_item, list)
            {
            @Override
            public View getView(int position, View convertView, ViewGroup parent)
            {
                if (convertView == null)
                    convertView = LayoutInflater.from(parent.getContext()).
                        inflate(R.layout.list_item, parent, false);

                final String text = list.get(position).activityInfo.
                    applicationInfo.loadLabel(pm).toString();
                ((TextView)convertView.findViewById(R.id.text)).setText(text);

                final …
Run Code Online (Sandbox Code Playgroud)

android

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

PackageManager未显示已安装的动态壁纸

我正在尝试加载设备上所有已安装软件包的列表,但是,当我这样做时,任何已安装的动态壁纸都不会显示在列表中...有没有办法解决这个问题?

这是我的代码:

final PackageManager pm = this.getPackageManager();

    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    final ArrayList<ResolveInfo> list =
            (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, 
                    PackageManager.PERMISSION_GRANTED);
    for (ResolveInfo rInfo : list)
    {
        Log.i(TAG, ": Installed Applications " + rInfo.activityInfo.
                applicationInfo.loadLabel(pm).toString());
    }

    final ArrayAdapter<ResolveInfo> adapter = 
        new ArrayAdapter<ResolveInfo>(this, R.layout.list_item, list)
        {
        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
            if (convertView == null)
                convertView = LayoutInflater.from(parent.getContext()).
                    inflate(R.layout.list_item, parent, false);

            final String text = list.get(position).activityInfo.
                applicationInfo.loadLabel(pm).toString();
            ((TextView)convertView.findViewById(R.id.text)).setText(text);

            final Drawable drawable = list.get(position).activityInfo.applicationInfo.loadIcon(pm);
            ((ImageView)convertView.findViewById(R.id.image)).setImageDrawable(drawable);

            return convertView; …
Run Code Online (Sandbox Code Playgroud)

android

0
推荐指数
1
解决办法
550
查看次数

如何禁用AlertDialog内的按钮?跟进问题

我昨天问了这个问题(http://stackoverflow.com/questions/7392321/how-do-you-disable-a-button-inside-of-an-alertdialog)并相应地修改了我的代码...今天早上我跑了模拟器中的代码并收到了NPE.这是代码:

public void monster() {
        int playerint = settings.getPlayerInt();
        int monsterint = settings.getMonsterInt();



        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage("You have Encountered a Monster");

        alertbox.setPositiveButton("Fight!",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        createMonster();
                        fight();

                    }
                });

        alertbox.setNeutralButton("Try to Outwit",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        // This should not be static
//                      createTrivia();
                        trivia();

                    }
                });

        // Return …
Run Code Online (Sandbox Code Playgroud)

android

-1
推荐指数
1
解决办法
4090
查看次数