警告消息:未使用字段CancelAnAlarmActivity.mDetailsButton的值 [英] Warning message: The value of the field CancelAnAlarmActivity.mDetailsButton is not used

查看:83
本文介绍了警告消息:未使用字段CancelAnAlarmActivity.mDetailsButton的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该程序正在我的仿真器和手机上运行,​​但我不明白为什么要在ADT上使用它。我的代码有问题吗?请检查。我需要帮助。如果我删除了这些行,则我的应用程序可能无法按照我希望的方式正常运行。

The program is running on my emulator and phone but I don't understand why i'm getting this on ADT. Is there something wrong with my codes? please check. i need help. If I remove this lines my app might not work properly according to how i wanted it to work.

这是我的Java代码之一:

here's one of my java codes:

import java.util.List;

import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;  <<-- This is where i get the warning message:"The import android.util.Log is never used"
import android.view.View;
import android.view.View.OnClickListener;  <<-- This is where i get the warning message:"The import android.util.Log is never used"
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;  <<-- This is where i get the warning message:"The import android.widget.Toast is never used"

public class CancelAnAlarmActivity extends ListActivity implements OnItemClickListener{
    private PendingIntentsDataSource mDatasource;
    private ListView mListView;
    private Button mDetailsButton;  <<-- This is where i get the warning message: The value of the field CancelAnAlarmActivity.mDetailsButton is not used
    private Button mCancelButton;  <<-- This is where i get the warning message:"The value of the field CancelAnAlarmActivity.mCancelButton is not used"
    private List<SMSSchedulerPendingIntent> mPendingIntentList;  <<-- This is where i get the warning message: "The value of the field CancelAnAlarmActivity.mPendingIntentList is not used"
    private String mNumberToSend;
    private String mReceiverName;
    private String mMessage;
    private String mFrequency;
    private static CancelAnAlarmActivity mCancelAlarmActivity;
    private int mIdOfAnPendingIntent;;

    //String newLine;
    String newL = System.getProperty("line.separator");
    @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mCancelAlarmActivity = this;
        mListView = getListView();

        //mDetailsButton = (Button)(findViewById(R.id.buttonDetails));
        mDatasource = new PendingIntentsDataSource(this);
        mDatasource.open();


        List<SMSSchedulerPendingIntent> values = mDatasource.getAllPendingIntents();

        final PendingIntentsArrayAdapter pendingIntentAdapter = new PendingIntentsArrayAdapter(this, R.layout.cancelanalarm, values);
        //setListAdapter(new PendingIntentsArrayAdapter(this, R.layout.cancelanalarm, values));
        setListAdapter(pendingIntentAdapter);
        //mDetailsButton = (Button)findViewById(R.id.buttonDetails);
        mPendingIntentList = pendingIntentAdapter.getPendingIntentList();

        mListView.setOnItemClickListener(this);

    }

    @Override
    public void onPause(){
        super.onPause();
        mDatasource.close();
        /*mEditTextMessage.setText("");
        mEditTextNumber.setText("");*/
    }
      @Override
    public void onResume(){
        super.onResume();
        mDatasource.open();
    }

    @Override
    public void onStart(){
        super.onStart();
        /*mEditTextMessage.setText("");
        mEditTextNumber.setText("");    */
        mDatasource.open();

    }
    @Override
    public void onStop(){
        super.onStop();
        /*mEditTextMessage.setText("");
        mEditTextNumber.setText("");    */  
        mDatasource.close();
    }

    @Override
    public void onDestroy(){
        super.onDestroy();
        /*mEditTextMessage.setText("");
        mEditTextNumber.setText("");*/
        mDatasource.close();
    }

    @Override
    public void onBackPressed(){
        mDatasource.close();
        Intent i = new Intent();
        i.setClassName("com.somitsolutions.android.smsscheduler", "com.somitsolutions.android.smsscheduler.SetuppageActivity");
        startActivity(i);
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        // TODO Auto-generated method stub
        //final String newLine = System.getProperty("line.seperator");
        SMSSchedulerPendingIntent selectedsmsSchedulerPendingIntent = (SMSSchedulerPendingIntent)(getListAdapter().getItem(arg2));
        mIdOfAnPendingIntent = (int) selectedsmsSchedulerPendingIntent.getId();
        mNumberToSend = selectedsmsSchedulerPendingIntent.getNumberToSend();
        mReceiverName = selectedsmsSchedulerPendingIntent.getReceiverName();
        mMessage = selectedsmsSchedulerPendingIntent.getMessage();
        mFrequency = selectedsmsSchedulerPendingIntent.getFrequency();
        String detailsTest = "Receiver's Number: "+ mNumberToSend + newL + "Receiver's Name: " + mReceiverName + newL + "Message: " + mMessage + newL + "Frequency: " + mFrequency;
        ShowCancelAlarmDetails(detailsTest);
        //mDetailsButton = (Button)(arg1.findViewById(R.id.buttonDetails));
        //mCancelButton = (Button)(arg1.findViewById(R.id.buttonCancel));
        /*mDetailsButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                String details = "Receiver's Number: "+ mNumberToSend + newL + "Receiver's Name: " + mReceiverName + newL + "Message: " + mMessage + newL + "Frequency: " + mFrequency;
                ShowCancelAlarmDetails(details);

            }
        });
        */
        /*mCancelButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                CancelAnAlarm(mIdOfAnPendingIntent);


            }
        });*/
    }

    public static CancelAnAlarmActivity getCancelAlarmActivity(){
        return mCancelAlarmActivity;
    }
    @SuppressWarnings("deprecation")
    public void  ShowCancelAlarmDetails(String message){
        //Toast.makeText(this, message, Toast.LENGTH_LONG).show();
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
        alertDialog.setTitle("Do you want to cancel this scheduled sms...");
        alertDialog.setMessage(message);
        //alertDialog.setCancelable(false);
        alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
              // TODO Add your code for the button here.
               CancelAnAlarm(mIdOfAnPendingIntent);
           }
        });
        alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialog, int which) {
              // TODO Add your code for the button here.
           }
        });
        alertDialog.show();
    }

    public void CancelAnAlarm(int id){
        AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(getApplicationContext().ALARM_SERVICE);
        Intent i = new Intent(getApplicationContext(), SendSMSAlarmService.class);
        PendingIntent pi = PendingIntent.getService(getApplicationContext(), id, i, PendingIntent.FLAG_UPDATE_CURRENT);
        am.cancel(pi);
        mDatasource.deletePendingIntent(id);
        Intent refresh = new Intent();
        refresh.setClassName("com.somitsolutions.android.smsscheduler", "com.somitsolutions.android.smsscheduler.CancelAnAlarmActivity");
        startActivity(refresh);
    }

    public void DeleteAnForOnceAlarmEntryFromDatabase(int id){
        mDatasource.deletePendingIntent(id);
        /*Intent refresh = new Intent();
        refresh.setClassName("com.somitsolutions.android.smsscheduler", "com.somitsolutions.android.smsscheduler.CancelAnAlarmActivity");
        startActivity(refresh);*/
    }
}

我在其他Java代码中收到了相同类型的警告消息。

I'm getting the same type of warning message in my other java codes.

推荐答案

您已将 mDetailsButton 声明为字段变量,但已对所有注释进行了注释包含此变量的零件。这就是为什么您会警告未使用的变量。

You have declared mDetailsButton as a field variable but you commented all the parts that contain this variable. That's why you got a warning of unused variable.

这篇关于警告消息:未使用字段CancelAnAlarmActivity.mDetailsButton的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆