小编Tof*_*mad的帖子

是否可以阻止用户在Android中卸载应用程序?

我想阻止用户卸载我的应用程序.但我的主要目标是在卸载applcation之前询问密码.这可能在android中.

security android

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

带有Fragment Activity的Android Back按钮?

嗨,大家好我正在开发一个扩展fragment活动的应用程序,这是我的问题,当我使用正常的活动是我使用下面的方法.

onKeyDown(KeyEvent.KEYCODE_BACK, newKeyEvent(KeyEvent.ACTION_DOWN,
                                                        KeyEvent.KEYCODE_BACK));
Run Code Online (Sandbox Code Playgroud)
  • 对于我需要做的活动?

我怎样才能实现这一目标

android android-fragments

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

引用主布局时出现空指针异常

我希望这种相对布局最终在底部加载广告.

public class Main extends Activity {
RelativeLayout mLayout;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);        
    setContentView(R.layout.main);
    mLayout = (RelativeLayout) findViewById(R.layout.main);  

    ImageView View = new ImageView(this, null);      //example view

    mLayout.addView(View);
Run Code Online (Sandbox Code Playgroud)

然后当调用mLayout时,Null指针发生在下面

 RelativeLayout.LayoutParams rparams = (LayoutParams) mLayout.getLayoutParams();
Run Code Online (Sandbox Code Playgroud)

E/AndroidRuntime(4066): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.name.project/com.name.project.Main}: java.lang.NullPointerException

xml用于布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
Run Code Online (Sandbox Code Playgroud)

知道为什么会发生这种情况吗?

android ads nullpointerexception android-layout

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

没有互联网连接时崩溃

没有interenet连接时,以下代码崩溃:

    public String gourl(String myurl,String params) {

        URL url;
        String rasp = "";

        try {
            url = new URL(myurl + params);
            BufferedReader rd = new BufferedReader(new InputStreamReader(
                    url.openStream()));
            String line = "";
            while ((line = rd.readLine()) != null) {
                rasp=rasp + line;
            }

            return rasp;
        } catch (Exception e) {
            Log.w("DHA", "EXCEPTIE URL");
        }       
        return null;
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能防止这种情况发生?

connection android

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