Tag: android intent

应用程序中的Android模式输入

我想知道是否有其他替代方案适用于Android的平庸EditText密码输入。 是否有可以集成到我的应用程序的API或开源代码,类似于锁定屏幕模式解锁? 也许Intent返回一个散列,数字,字符串或代表用户的Pattern输入的任何东西。 我在想类似的东西。 我的代码称之为意图。 类似于Lockscreen Pattern的东西显示 用户输入他的模式 Intent返回表示该模式的内容。 我取消了返回的数据。 我为什么要/需要这个? 在我的应用程序中,我需要来自用户的输入密码(不用于登录或用于加密的东西)。 而且我认为用户输入是很乏味的。 这些刷卡锁模式会更容易。

如何将带有recyclelerview的一个活动中的json资产文件中的arraylist收集的数据传递给另一个具有回收者视图的活动?

我有一个名为Cardview Activity ,它有一个与之关联的回收站视图,我从中获取JSON资产文件中的数据。 但是现在当我点击Cardview活动的项目时,我想将与该项目相关的数据仅发送到另一个活动,即People_List_Activity ,它再次具有recyclerView。 CardViewActivity.java package com.example.android.directory; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.widget.EditText; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; public class CardViewActivity extends AppCompatActivity { Toolbar mActionBarToolbar; private RecyclerView mainRecyclerView; private RecyclerView.Adapter mainAdapter; private RecyclerView.LayoutManager mainLayoutManager; […]

Android Studio:使用intent PROVIDES仅传递多个值1 VALUE?

我正在尝试进行测验,用户在每个活动中选择答案,最后一页根据所选选项提供答案。 因此,我想将这些值传递给最终活动,但只显示最后选择的值。 第一项活动: public class Quiz extends Activity { Button btn; RadioGroup rg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.quiz); btn = (Button) findViewById(R.id.nextBtn); rg= (RadioGroup) findViewById(R.id.rg); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (rg.getCheckedRadioButtonId() == -1) { Toast.makeText(getApplicationContext(), “Please select an answer”, Toast.LENGTH_SHORT).show(); } else{ Intent intent = new Intent(getApplicationContext(), […]

NullPointer在为TextView赋值时发生exception

我只是想将值从一个活动传递到另一个活动,但无法从视图中找到Textview值。我只是通过文本框将一条消息从主活动传递给此活动,我在这里看到文本框值但不能将其分配给textView … 这是我的代码.. public class DisplayMessageActivity extends Activity { private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_message); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } textView = (TextView) findViewById(R.id.displayText); Intent intent = getIntent(); String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); textView.setText(message); } XML 请帮帮我..

将文件从内部存储复制到外部存储

我试图使用Adobe阅读器阅读从服务器下载的pdf文件问题是当我将其存储在内部存储中时其他应用程序无法读取该文件。 现在我想知道如何在外部存储(/ sdcard /)中 复制此文件,以便pdf查看器可以查看。 由于安全原因,我将文件存储在内部存储中,然后删除外部存储中的文件。 我的问题是如何复制保存在内部存储中的文件,而不使用raw或资产放入输入流。 InputStream myInput = getResources().openRawResource(R.raw.p13); FileOutputStream fos = openFileOutput(“sample”, Context.MODE_PRIVATE); // transfer bytes from the input file to the output file byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) > 0) { fos.write(buffer, 0, length); } // Close the streams fos.flush(); fos.close(); myInput.close();

添加日历活动而不打开日历

在我的应用程序中,用户可以为任务设置最多3个提醒,但每次按“设置提醒”按钮时,它都会打开日历应用程序。 有没有办法在不打开默认日历应用程序的情况下设置日历事件? 我只是想在不启动日历活动的情况下添加事件。 这就是我现在的代码: Calendar beginTime = Calendar.getInstance(); beginTime.set(2013, Calendar.MAY, 10, 3, 00); startMillis = beginTime.getTimeInMillis(); Calendar endTime = Calendar.getInstance(); endTime.set(2012, Calendar.MAY, 10, 4, 00); endMillis = endTime.getTimeInMillis(); Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType(“vnd.android.cursor.item/event”); intent.putExtra(Events.TITLE, “Test Android”); intent.putExtra(Events.EVENT_LOCATION, “Test Location”); intent.putExtra(Events.DESCRIPTION, “Test Description Examples”); intent.putExtra(Events.DTSTART, startMillis); intent.putExtra(Events.DTEND, endMillis); intent.putExtra(Events.ALL_DAY, false); intent.putExtra(Events.EVENT_END_TIMEZONE, “Europe/London”); intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE); intent.putExtra(Events.AVAILABILITY, […]

Android:如何在应用程序执行其他工作时持续保存传感器数据

我刚接触到android。 我正在开发一个应用程序,以持续保存传感器的数据,然后拍摄照片。 事实上,我想在拍照时开始将加速度计数据保存到文件中,或者屏幕显示为黑屏。 我已达到这一点,我的应用程序在触摸按钮时保存传感器数据,但它只执行一次。 如何让它连续保存数据而不影响我的应用程序的其他部分运行? 我希望它保存数据,而我正在我的应用程序中拍照,当屏幕被遮挡,而我已经离开我的应用程序(例如应用程序暂停) plz hlp thnx。 这是我的代码 private OnClickListener saveFun =new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub try { File root = Environment.getExternalStorageDirectory(); if (root.canWrite()){ File f = new File(root, “test.txt”); FileWriter fw; if ( saveBtnCnt == 0){ fw = new FileWriter(f); saveBtnCnt = 1; } […]

android服务START_STICKY START_NOT_STICKY

我需要保持我的服务始终在后台运行。 并使用“startService()”函数启动我的服务。 我不希望重新启动任何应用程序状态的服务。 这是我的观察。 START_STICKY>如果应用程序启动,则服务正在重新启动。 当应用程序关闭时,服务也会重新启动。 应用程序关闭后,START_NOT_STICK>服务无效。 我需要一个始终运行的服务,它将在应用程序启动时接收广播。 服务状态不依赖于应用程序是否正在运行。 你能帮助我吗 ? 谢谢。

通过Bundle静态变量或传递变量?

假设我有一个ListView,我在列表上设置了一个OnItemClickListener。 传递变量的最佳方法是什么? 静态变量: public static String example; // onItemClick Intent intent = new Intent(Main.this, Details.class); Main.example = “example”; startActivity(intent); // in onCreate of Details String example = Main.example; 束: // onItemClick Intent intent = new Intent(Main.this, Details.class); intent.putExtra(“example”,”example”); startActivity(intent); // in onCreate of Details Bundle extras = getIntent().getExtras(); String example = extra.getString(“example”); // or Intent […]

Android – 从最近的应用程序中滑动应用程序时停止服务

我开发了一个Android应用程序,其服务在后台运行,服务就像这样调用 startService(new Intent(getApplicationContext(),myService.class)); 但是当我从最近的应用程序中删除该应用程序时,如果我测试它,服务就会停止并崩溃..有没有办法阻止从最近的应用程序中刷出应用程序时服务被破坏? 谢谢