我有一个服务类.我已将此类导出到jar,并且已将jar嵌入到我的客户端应用程序中.
需要时,我会调用服务类.当我尝试这样做时,我收到以下错误:
Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found
Run Code Online (Sandbox Code Playgroud)
除了服务类之外,我还有其他类,我可以访问它(创建该类的对象),它们位于同一个jar中.
我觉得我错过了我的配置或清单中的一些东西.
请帮我识别一下.我的代码如下:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent () ;
intent.setClassName("com.sample.service" ,"com.sample.service.serviceClass") ;
this.startService(intent) ; // when I call this line I get the message...
// binding other process continue here
}
Run Code Online (Sandbox Code Playgroud)
客户端manifest.xml
<service android:name="com.sample.service.serviceClass"
android:exported="true" android:label="@string/app_name"
android:process=":remote">
<intent-filter><action android:name="com.sample.service.serviceClass"></action>
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
提前谢谢,
Vinay
我正在开发一个Android应用程序,它打开MIC源并记录麦克风的音频.我有另一个单独的线程在后台运行,它清除ArrayList,定期保存麦克风的音频输入(每1秒)
它工作正常约5至7分钟,我得到一个这样的错误信息
Consumer closed input channel or an error occur...
Run Code Online (Sandbox Code Playgroud)
并且应用程序被终止.在收到错误消息之前,它会显示此消息并终止应用程序.如何解决此问题以及可能导致此错误的原因?提前致谢.
05-26 18:51:08.137: INFO/DEBUG(2894): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-26 18:51:08.137: INFO/DEBUG(2894): Build fingerprint: 'google/passion_kt/passion:2.3.3/GRI40/49208:user/release-keys'
05-26 18:51:08.137: INFO/DEBUG(2894): pid: 2956, tid: 2956 >>> com.company.app.p2p <<<
05-26 18:51:08.137: INFO/DEBUG(2894): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 45088dbc
05-26 18:51:08.137: INFO/DEBUG(2894): r0 42089000 r1 ffffffff r2 00000000 r3 ffffffff
05-26 18:51:08.137: INFO/DEBUG(2894): r4 20000000 r5 e8001200 r6 40009228 r7 00000001 …Run Code Online (Sandbox Code Playgroud) 我有一个AutoCompleteTextView,其列表从自定义ArrayAdapter加载.
在视图中,我有2行一个名称,第二个是电子邮件ID.
我的问题是,当我在列表中有一个项目时,它会裁剪项目.(请参阅附图)

任何想法如何解决这个问题?
提前致谢.
更新:看起来像一个褪色的问题,有人能帮助我消除这种褪色吗?
这里类似的线程没有帮助的答案...我想创建带文件附件的电子邮件,文件在内部存储上.这是代码:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{email});
i.putExtra(Intent.EXTRA_SUBJECT, "Smart Weight Tracker");
i.putExtra(Intent.EXTRA_TEXT , "CSV file is in attachment");
Uri uri;
if(useExternal){
uri = Uri.fromFile(new File(this.getExternalFilesDir(null),fname));
}
else{
File f = new File(this.getFilesDir(),fname);
f.setReadable(true, false);
f.setWritable(true, false);
uri = Uri.fromFile(f);
}
i.putExtra(Intent.EXTRA_STREAM, uri);
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
它与外部存储完美配合,但在使用内部存储时我没有附加功能.我检查了 - 文件打开,(通过显示Toast在我的应用程序中的长度 - 是的,> 0).
我这样写:
OutputStreamWriter out =
new OutputStreamWriter(con.openFileOutput(fname, Context.MODE_WORLD_READABLE));
Run Code Online (Sandbox Code Playgroud)
在logcat我看到了
I/Gmail …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个UI,在其中我具有在XML中定义的线性布局。
根据用户的输入,我需要向此线性布局添加一些TextView。我能够做到这一点。
我的实际问题是,当我拥有更多的文本视图时,它们彼此并排堆叠,并且某些文本视图的文本被隐藏或垂直拉伸,如下图所示。

我想使用线性布局的整个宽度,如果文本视图不能容纳在此行中,则应将其放在新行中或第一个文本视图的下面。我希望显示如下。

以下是我在XML中的线性布局配置:
<RelativeLayout
android:id="@+id/RL1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingBottom="5dip"
android:paddingTop="5dip" >
<TextView
android:id="@+id/text1"
android:layout_width="85dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:gravity="left"
android:text="Lable 1"
android:textColor="#999999" />
<LinearLayout
android:id="@+id/LL1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/button1"
android:layout_toRightOf="@+id/text1"
android:gravity="left|center_vertical"
android:orientation="horizontal"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="3dip" >
</LinearLayout>
<Button
android:id="@+id/button1"
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginTop="2dip"
android:background="@drawable/plus"
android:clickable="true"
android:focusable="true"
android:paddingTop="5dip" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我如何在Java代码中重新对齐相同的内容。
android alignment textview android-layout android-linearlayout
如果手机连接到网络,我的应用会立即收到GCM消息.但是,当用户关闭网络并在长时间间隔(约2小时)后重新连接时,设备不会收到消息.
我没有添加TTL,所以假设它将是4周.
正在发送的示例消息:
{
"registration_ids":["APA9xxx........."],
"delay_while_idle":false,
"collapse_key":"New Message",
"restricted_package_name":"com.sample.gcm",
"data":{
"app":2,
"product":"message",
"notif":"03lm9h"
}
}
Run Code Online (Sandbox Code Playgroud)
我错过了一些东西确实能让它在交货延迟时起作用吗?
请指出,这些链接可以帮助我解决这个问题.
提前致谢.
我有一个服务组件(我所有应用程序的常见任务),可以由任何应用程序调用.我试图从所有活动中访问服务对象,我注意到创建服务的那个[startService(intent)]具有正确的信息.但是休息并不需要信息.我的代码如下:
// Activity.java
public void onCreate(Bundle savedInstanceState) {
...
Intent intent = new Intent (this.context, Service.class) ;
this.context.startService(intent) ;
this.context.bindService(intent, this, Context.BIND_AUTO_CREATE) ;
...
String result = serviceObj.getData() ;
}
public void onServiceConnected(ComponentName name, IBinder service) {
serviceObj = ((Service.LocalBinder)service).getService();
timer.scheduleAtFixedRate(task, 5000, 60000 ) ;
}
// Service.java
private final IBinder mBinder = new LocalBinder();
public class LocalBinder extends Binder {
Service getService() {
return Service.this;
}
}
public void onCreate() {
super.onCreate();
context = getApplicationContext() ;
}
public void …Run Code Online (Sandbox Code Playgroud)