我正在开发一个应用程序,我想从收件箱中删除所有短信.为此,我使用了以下代码.
Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = getContentResolver().query(uriSms, null,null,null,null);
int id = c.getInt(0);
int thread_id = c.getInt(1); //get the thread_id
getContentResolver().delete(Uri.parse("content://sms/conversations/" + thread_id),null,null);
Run Code Online (Sandbox Code Playgroud)
此代码不起作用.有没有办法做同样的事情?
如果某些条件返回true,我想重定向页面.我不知道该怎么做.任何人都能为我提供一个例子吗?
或者有什么方法可以实现这一目标吗?
我通过我的申请发送邮件.为此,我使用以下代码.
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
它只是工作正常,但我想附加一个xml文件.可能吗?怎么样?
我想在Android手机中添加一个新的联系人.为此,我使用以下代码.
ContentValues values = new ContentValues();
values.put(Phone.RAW_CONTACT_ID, "jadeja");
values.put(Phone.NUMBER, 1234567890);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
Uri uri = getContentResolver().insert(Phone.CONTENT_URI, values);
Run Code Online (Sandbox Code Playgroud)
但它强制关闭应用程序并在"LogCat"内部显示安全权限被拒绝.有没有办法实现这个目标?
我正在尝试使用代码点火器框架上传图像,因为我的控制器类代码如下
public function addNewSlider()
{
if($this->session->userdata('logged_in'))
{
$this->form_validation->set_rules('title','Title','required');
if($this->form_validation->run()===FALSE)
{
$data['content']=$this->input->get_post('content');
$data['file']=$this->input->get_post('file');
$data['status']=$this->input->get_post('status');
$this->load->view('admin/templates/header',array('sessionArray'=>$this->sessionArray));
$this->load->view('admin/sliders/addNewSlider',$data);
$this->load->view('admin/templates/footer');
}
else
{
/*$title=$this->input->get_post('title');
$content=$this->input->get_post('content');
$image=$this->input->get_post('file');
$status=$this->input->get_post('status');
$this->sliders_model->insertNewMenu($title,$content,$image,$status);
redirect('sliders','refresh');*/
}
}
else
{
redirect('index','refresh');
}
}
function do_upload()
{
$name=time();
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
// $config['max_size'] = '100';
// $config['max_width'] = '1024';
//$config['max_height'] = '768';
$config['file_name']=$name;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
print_r($error);exit;
//$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
//$this->load->view('upload_success', $data);
} …Run Code Online (Sandbox Code Playgroud)