我有三个活动:
我必须将var"Name"从登录传递给选择(并且这项工作很好)然后,从选择到输入,这就是我遇到问题的地方:/我可以将名称传递给选择,但是当我尝试传递它时进入,我不能!这很奇怪,因为如果我直接从登录到条目传递变量,它可以工作:/所以:
这是从登录到选择的代码
Intent intent;
String pkg=getPackageName();
intent=new Intent(getApplicationContext(), scelta.class);
//inseriamo i dati nell'intent
String parts[] = risp.split("/");
intent.putExtra(pkg+".myNome", parts[0]);
intent.putExtra(pkg+".myId", parts[1]);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这是选择(可能是错误):
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scelta);
// l'intent di questa activity
Intent intent=getIntent();
String pkg=getPackageName();
//prendiamo i dati
String nome=intent.getStringExtra(pkg+".myNome");
String Id=intent.getStringExtra(pkg+".myId");
intent.putExtra(pkg+".myNome", nome);
intent.putExtra(pkg+".myId", Id);
TextView tvNome = (TextView) findViewById(R.id.txtNome);
tvNome.setText(nome);
}
//pulsante per il checkin
public void checkin (View v) { …Run Code Online (Sandbox Code Playgroud) 我想使用此代码使用BroadcastReceiver启动服务
public void onReceive(Context context, Intent intent) {
Intent myIntent = new Intent(context,BlueToothService.class);
context.startService(myIntent);
}
Run Code Online (Sandbox Code Playgroud)
但无法启动该服务.我还在清单中注册了服务和接收者.
我也有一个疑问,我们可以在没有活动的情况下使用广播接收器吗?
这是我的服务类
public class BlueToothService extends Service {
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStartCommand(Intent intent, int startId) {
super.onStart(intent, startId);
Toast.makeText(this, "service Started", Toast.LENGTH_LONG);
doBluetoothJob();
}
Run Code Online (Sandbox Code Playgroud)
我的清单文件看起来像这样.
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BROADCAST_SMS" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
</application>
<service
android:name=".BlueToothService"
android:enabled="true" >
</service>
<receiver android:name="com.simsys.bt.DemoBT" >
</receiver>
<intent-filter>
<category …Run Code Online (Sandbox Code Playgroud) 我正在Activity使用调用Intent,并且需要Activity在初始化时将变量传递给。在iOS上,您可以使用使用initWithNibName方法的自定义初始化。如何在Android上实现类似的目标?
这是我的代码,创建一个Intent...
Intent myIntent = new Intent(webPush.this, webPushActivity.class);
startActivity(myIntent);
Run Code Online (Sandbox Code Playgroud) 我已经设置了两个按钮.一个打开compose短信意图,另一个打开撰写电子邮件意图.短信意图工作正常但电子邮件按钮没有响应.我已经创建了一个categorychooser但是没有显示....直到我点击短信按钮
这是我的代码
case R.id.button2:
{
String phoneNumber = "xxxxxxxxxx";``
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setType("vnd.android -dir/mms-sms");
smsIntent.setData(Uri.parse("sms:"+phoneNumber));
startActivity(smsIntent);
}
case R.id.button3:
{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"xxxxxxxx@gmail.com"});
emailIntent.setType("plain/text");
startActivity(Intent.createChooser(emailIntent, "Send email..."));
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
所以我正在尝试开发自定义锁屏
但我的广播接收器不会发射
我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.alexander.fuchs.lockscreen"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".app"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".myreceiver">
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF"/>
<action android:name="android.intent.action.SCREEN_ON"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我的接收者:
public class myreceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("receiver","works");
Toast.makeText(context,"works",Toast.LENGTH_LONG).show();
Intent in=new Intent(context,app.class);
context.startActivity(in);
}
}
Run Code Online (Sandbox Code Playgroud)
接收器应该告诉我它被触发:D但是它不是logcat中的任何日志
我想在内部存储中保存文件.下一步是我要读取文件.使用FileOutputStream在内部存储中创建文件,但读取文件时出现问题.
是否可以访问内部存储来读取文件?
我有一个简单的疑问.在Android中它被说几乎无处不在,要经过一个String或intü应该使用或任何Intent与使用putextra()或任何传递过来,明年activity在那里,我可以从任何创建静态对象和访问activity
必须有使用背后的意图的话,任何人都可以请让我清醒为什么我们需要某种原因,intent从一个传递一个对象activity到其他地方,我们可以做到这一点为常,因为我们做它在Java.
我有一个主菜单活动,有一堆按钮.一个按钮启动一个新活动,允许用户填写并提交表单.当用户提交表单时,第三个活动开始,基本上只是一个包含一些内容的屏幕和一个返回主菜单的按钮.但是,当我创建一个intent并转到main活动时,setContentView()不起作用,我的按钮赋值会导致NullPointerException.
我知道有一些方法可以通过意图标志或调用finish()返回堆栈.我没有成功的意图标志,如Intent.FLAG_ACTIVITY_CLEAR_TOP.完成()将无法工作,因为我是两个活动,而不是一个.回到主要活动的正确方法是什么?
谢谢
我在活动中使用listview和slidedrawer.我的目的是打开slidedrawer并在列表项单击时显示内容.slidedrawer内容将根据所选项目进行更改.
UI布局如下所示.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/presentation_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<SlidingDrawer
android:id="@+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="horizontal" >
<Button
android:id="@+id/handle"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:background="@android:color/darker_gray" />
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Presentation's Images.. Please Flip"
android:textColor="@android:color/black"
android:textStyle="bold" />
<ImageView
android:id="@+id/content_imageview"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@android:color/black"
android:layout_below="@id/presentation_list"
/>
</LinearLayout>
</SlidingDrawer>
Run Code Online (Sandbox Code Playgroud)
我点击listview滑块打开,当我点击slidedrawer的imageview时,我的listview也被点击了.控件进入listview项目单击方法并且图像被更改
任何人都可以帮我纠正这个问题吗?
我正在开发一个Android应用程序,在其中,我想获得正在运行的进程或应用程序列表.我找到了一种使用activitymanager的方法.但我不知道的是如何获得每个进程使用的处理器和内存.是否有人知道如何实现这一目标.
获取正在运行的进程的代码是,
我从上面的代码中获取所有正在运行的应用程序进程.请帮助我获取列表中每个进程的值.
谢谢.