小编GVi*_*i82的帖子

用于启动服务的Android onCreate或onStartCommand

通常当我创建Android服务时,我实现了该onCreate方法,但在我的上一个项目中,这不起作用.我尝试实现onStartCommand,这似乎工作.

问题是:当我必须实现一个需要哪种方法的服务时?我必须实施哪些方法?onCreate,onStartCommand或两者兼而有之?每个人的角色是什么?

android android-service oncreate

90
推荐指数
2
解决办法
7万
查看次数

将POST中的json发送到Web API服务时出错

我正在使用Web API创建一个Web服务.我实现了一个简单的类

public class ActivityResult
{
    public String code;
    public int indexValue;
    public int primaryCodeReference;
}
Run Code Online (Sandbox Code Playgroud)

然后我在我的控制器内实现了

[HttpPost]
public HttpResponseMessage Post(ActivityResult ar)
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}
Run Code Online (Sandbox Code Playgroud)

但是当我调用API传递POST文件时json:

{"code":"XXX-542","indexValue":"3","primaryCodeReference":"7"}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:

{
    "Message": "The request entity's media type 'text/plain' is not supported for this resource.",
    "ExceptionMessage": "No MediaTypeFormatter is available to read an object of type 'ActivityResult' from content with media type 'text/plain'.",
    "ExceptionType": "System.Net.Http.UnsupportedMediaTypeException",
    "StackTrace": "   in System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n   in System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net json asp.net-web-api

90
推荐指数
1
解决办法
12万
查看次数

无法为io.reactivex.Observable创建调用适配器

我将向我的服务器(它是Rails应用程序)发送一个简单的get方法,并使用RxJava和Retrofit获取结果.我做的是:

我的界面:

public interface ApiCall {
    String SERVICE_ENDPOINT = "https://198.50.214.15";
    @GET("/api/post")
    io.reactivex.Observable<Post> getPost();
}
Run Code Online (Sandbox Code Playgroud)

我的模型是这样的:

public class Post
{
    @SerializedName("id")
    private String id;
    @SerializedName("body")
    private String body;
    @SerializedName("title")
    private String title;

    public String getId ()
    {
        return id;
    }


    public String getBody ()
    {
        return body;
    }


    public String getTitle ()
    {
        return title;
    }

}
Run Code Online (Sandbox Code Playgroud)

这就是我在活动中所做的:

public class Javax extends AppCompatActivity {
    RecyclerView rvListContainer;
    postAdapter postAdapter;
    List<String> messageList=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_javax);

        rvListContainer=(RecyclerView)findViewById(R.id.recyclerView);
        postAdapter=new …
Run Code Online (Sandbox Code Playgroud)

rx-java retrofit rx-android retrofit2 rx-java2

85
推荐指数
4
解决办法
3万
查看次数

如何在Eclipse中显示Project Explorer窗口

突然,我的项目浏览器窗口从Eclipse中消失了.我尝试选择Windows> Show View> Project Explorer,但没有任何反应.我能做什么?

eclipse

78
推荐指数
7
解决办法
20万
查看次数

启动Android服务已经运行?

当然这是一个微不足道的问题.如果我Service使用以下代码启动a会发生什么:

 startService(new Intent(this,myService.class));
Run Code Online (Sandbox Code Playgroud)

然后我不小心回想起上面的代码,而它还在Service运行?

我担心第二次调用startservice可以创建一个新的Service,以便同时执行两个不同的进程.

service android android-intent

37
推荐指数
1
解决办法
1万
查看次数

将选择结果作为存储过程的参数传递

我有一个带有以下参数的T-SQL存储过程

CREATE PROCEDURE [dbo].[SaveData]
-- Add the parameters for the stored procedure here
    @UserID varchar(50),
    @ServiceID varchar(50),
    @param1 varchar(50),
    @param2 varchar(50),
    @endDate datetime
AS BEGIN
    . 
    .
    -- my code --
Run Code Online (Sandbox Code Playgroud)

我想知道是否可以传递select参数的结果:

    exec SaveDate (SELECT player.UserID,player.ServiceID, 'no','no',GETDATE()
           FROM player)
Run Code Online (Sandbox Code Playgroud)

我试过这样的东西,但它不起作用.

sql sql-server parameters select stored-procedures

20
推荐指数
2
解决办法
7万
查看次数

使用ExoPlayer重现加密视频

我在Android中使用ExoPlayer,我正在尝试重现本地存储的加密视频.

ExoPlayer的模块化允许创建可以在ExoPlayer中注入的自定义组件,这似乎就是这种情况.事实上,经过一些研究,我意识到,为了实现这个任务,我可以创建一个自定义DataSource并覆盖open(),read()close().

我也找到了这个解决方案,但实际上这里整个文件只需一步解密并存储在一个清晰的输入流中.在许多情况下这可能是好的.但是,如果我需要重现大文件怎么办?

所以问题是:如何在ExoPlayer中重现加密视频,"在运行中"解密内容(不解密整个文件)?这可能吗?

我尝试创建一个具有open()方法的自定义DataSource:

@Override
    public long open(DataSpec dataSpec) throws FileDataSourceException {
        try {
            File file = new File(dataSpec.uri.getPath());

            clearInputStream = new CipherInputStream(new FileInputStream(file), mCipher);

            long skipped = clearInputStream.skip(dataSpec.position);
            if (skipped < dataSpec.position) {
                throw new EOFException();
            }
            if (dataSpec.length != C.LENGTH_UNBOUNDED) {
                bytesRemaining = dataSpec.length;
            } else {
                bytesRemaining = clearInputStream.available();
                if (bytesRemaining == 0) {
                    bytesRemaining = C.LENGTH_UNBOUNDED;
                }
            }
        } catch (EOFException e) {
            e.printStackTrace();
        } …
Run Code Online (Sandbox Code Playgroud)

encryption android android-mediaplayer exoplayer

19
推荐指数
2
解决办法
3438
查看次数

jQuery:删除数据表中的行

我正在使用jquery数据<tr>表,我在表中有一些具有以下结构:

<tr class="odd">
     <td class="  sorting_1">0</td>
     <td class=" ">2011</td>
     <td class=" ">20</td>
     <td class=" ">
         <span class="btn-group">
            <a class="del btn btn-small" href="#"><i class="icon-delete"></i></a>       
         </span>
     </td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我写了下面的jquery代码,用于删除与我点击的按钮相关联的行.

$(".del").bind("click", function(event){
        var target_row = $(this).parent().parent().parent();
        var aPos = oTable.fnGetPosition(target_row); // the error occurs here!
        oTable.fnDeleteRow(aPos);
          });
Run Code Online (Sandbox Code Playgroud)

但我得到这样的错误:

"TypeError: a.nodeName is undefined" 在jquery min脚本文件中.

编辑:

这里是创建数据表的代码:

if( $.fn.dataTable ) {
            $(".mws-datatable").dataTable();
            var oTable = $(".mws-datatable-fn").dataTable({
                bRetrieve: true,
            sPaginationType: "full_numbers"
            });
        }
Run Code Online (Sandbox Code Playgroud)

html javascript jquery dom datatables

18
推荐指数
1
解决办法
3万
查看次数

Android:LinearLayout中奇怪的权重反转

这是我正在研究的xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <ScrollView 
        android:layout_weight="2" 
        android:id="@+id/scrollConfirm" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

  </ScrollView>

  <LinearLayout 
      android:layout_marginTop="20px"
      android:layout_weight="1" 
      android:id="@+id/imageNumpad" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent">
        <ImageView android:src="@drawable/myicon"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#FFFFFF"
        />
   </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

由于我已经设置了ScrollView layout_weight="2"和LinearLayout(子),layout_weight="1"我预计ScrollView会占用LinearLayout两倍的可用空间.但我得到了相反的结果.ScrollView小于LinearLayout.而如果我为ScrollView layout_weight="1"和LinearLayout设置layout_weight="2",则ScrollView大于LinearLayou.

这怎么可能??

android android-linearlayout android-view

12
推荐指数
1
解决办法
2237
查看次数

BitmapFrame.Create的例外(WPF框架中的错误?)

我实现了一个C#应用程序,它以30fps的帧速率接收帧RGB.

使用以下代码管理帧到达事件:

void client_ColorFrameReady(object sender, ColorFrameReadyEventArgs e)
        {
            mycounter++;
            Console.WriteLine("new frame received: " + mycounter);

            if (writer != null)
            {
                count++;
                if (count % 2== 0)
                {

                    using (var frame = BitmapImage2Bitmap(e.ColorFrame.BitmapImage))
                    using (var thumb = ResizeBitmap(frame, 320, 240))
                    {
                        writer.WriteVideoFrame(thumb);
                    }

                }
            }
            else
            {
                writer.Close();
            }
        }
Run Code Online (Sandbox Code Playgroud)

使用if条件我只管理两个帧中的一个.

当我的代码调用时,BitmapImage2Bitmap我获得了这个异常:

在此输入图像描述

英语中的例外应该是:

A first chance exception of type 'System.NotSupportedException' occurred in `PresentationCore.dll`
Additional information: BitmapMetadata is not available on BitmapImage.
Run Code Online (Sandbox Code Playgroud)

奇怪的是,我的应用程序"运行良好",因为帧已正确插入输出文件中.

我已经读过这个,所以问题似乎是WPF框架中的一个错误.

.net c# exception try-catch

10
推荐指数
2
解决办法
7100
查看次数